Contest1539 - 2019年我能变强组队训练赛第十一场

Greater New York 2012

Hailstone HOTPO

#pragma GCC optimize(3,"Ofast","inline")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
    ll n;
    int T;
    cin>>T;
    while(T--)
    {
        ll k;
        scanf("%lld %lld",&k,&n);
        ll maxd=0;
        ll x=n;
        maxd=x;
        while(x!=1)
        {
            if(x%2==1)
            {
                x=x*3+1;
            }
            else{
                x/=2;
            }
            maxd=max(maxd,x);
        }
        printf("%lld %lld\n",k,maxd);
    }
    return 0;
}

Casting

#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e7 + 10;
const int N = 28;
int p,b,k;

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.txt", "r", stdin);
#endif
    scanf("%d",&p);
    while(p--){
        int res=0;
        scanf("%d%d",&k,&b);
        char ch;
        //getchar();
        while(ch=getchar(),ch!=‘\n‘){
            if(ch>=‘0‘&&ch<=‘9‘) {
                res = (res * b) % (b - 1);
                res = (res + ch - ‘0‘) % (b - 1);
                res %= (b - 1);
            }
            //printf("***");
        }
        printf("%d %d\n",k,res);
    }
    return 0;
}

Pen Counts

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
inline int read()
{
    ll res=0,f=1;
    char ch=getchar();
    while (!isdigit(ch))
    {
        if (ch==‘-‘)
        {
            f=-f;
        }
        ch=getchar();
    }
    while (isdigit(ch))
    {
        res=(res<<3)+(res<<1)+ch-‘0‘;
        ch=getchar();
    }
    return f*res;
}
int main() {
    ll _=read();
    while (_--) {
        ll n, k, b, a, ans=0;
        k=read();n=read();
        for (ll i = 1; i <= n / 3; i++) {
            b = (n - i) / 2;
            a = max(i, n / 2 - i + 1);
            ans += (b - a + 1) * 2;
            if (i == a) ans--;
            if (i != b && b == n - i - b) ans--;
        }
        printf("%lld %lld\n", k, ans);
    }
}

Faulhaber’s Triangle

import java.util.Scanner;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        BigInteger f[][][] = new BigInteger[410][410][3];
        f[0][1][0] = BigInteger.ONE;
        f[0][1][1] = BigInteger.ONE;
        for (int i = 1; i <= 400; i++) {
            BigInteger mu = BigInteger.ONE;
            for (int j = i + 1; j >= 2; j--) {
                BigInteger ii = BigInteger.valueOf(i);
                f[i][j][0] = f[i - 1][j - 1][0].multiply(ii);
                BigInteger jj = BigInteger.valueOf(j);
                f[i][j][1] = f[i - 1][j - 1][1].multiply(jj);
                if (f[i][j][1].compareTo(BigInteger.ZERO) != 0) mu = mu.multiply(f[i][j][1]);
                BigInteger d = f[i][j][0].gcd(f[i][j][1]);
                if (d.compareTo(BigInteger.ZERO) != 0) {
                    f[i][j][0] = f[i][j][0].divide(d);
                    f[i][j][1] = f[i][j][1].divide(d);
                }
            }
            BigInteger zi = BigInteger.ZERO;
            for (int j = 2; j <= i + 1; j++) {
                if (f[i][j][1].compareTo(BigInteger.ZERO) != 0)   zi = zi.add(mu.divide(f[i][j][1]).multiply(f[i][j][0]));
            }
            BigInteger d = mu.gcd(zi);
            mu = mu.divide(d);
            zi = zi.divide(d);
            if (mu.compareTo(zi) == 0) {
                f[i][1][0] = BigInteger.ZERO;
                f[i][1][1] = BigInteger.ZERO;
            } else {
                if (mu.compareTo(zi) > 0) {
                    f[i][1][0] = mu.subtract(zi);
                    f[i][1][1] = mu;
                } else {
                    f[i][1][0] = zi.subtract(mu).multiply(BigInteger.valueOf(-1));
                    f[i][1][1] = mu;
                }
            }
        }

        int T = cin.nextInt();
        for (int i = 1; i <= T; i++) {
            int a = cin.nextInt(), b = cin.nextInt(), c = cin.nextInt();
            System.out.print(a + " ");
            if (f[b][c][0].compareTo(BigInteger.ZERO) == 0) {
                System.out.println("0");
            } else if (f[b][c][1].compareTo(BigInteger.ONE) == 0) {
                System.out.println(f[b][c][0]);
            } else System.out.println(f[b][c][0] + "/" + f[b][c][1]);
        }
    }
}

The King’s Ups and Downs

#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e7 + 10;
const int N = 28;
ll e[28]={0,1,2,4,10,32,122,544,2770,15872,101042,707584,5405530,44736512,398721962,3807514624,38783024290,419730685952,4809759350882,58177770225664,740742376475050};
int p,d,n;
int main() {
//#ifndef ONLINE_JUDGE
//    freopen("1.txt", "r", stdin);
//#endif
    scanf("%d",&p);
    while(p--){
        scanf("%d%d",&d,&n);
        printf("%d %lld\n",d,e[n]);
    }
    return 0;
}

  

  

原文地址:https://www.cnblogs.com/Accpted/p/11425624.html

时间: 2024-10-09 12:31:13

Contest1539 - 2019年我能变强组队训练赛第十一场的相关文章

Contest1814 - 2019年我能变强组队训练赛第七场

Scores of Final Examination On-Screen Keyboard Tally Counters Balance Scale #pragma GCC optimize(3,"Ofast","inline") #include <bits/stdc++.h> using namespace std; typedef long long ll; unordered_map<ll,bool> m1; int n,m,cnt

Contest1657 - 2019年我能变强组队训练赛第十四场

Contest1657 - 2019年我能变强组队训练赛第十四场 Similarity of Subtrees #include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; const int maxn=100100; ull ha[maxn]; vector<int>E[maxn]; unordered_map<ull,int>m;

1780 - 2019年我能变强组队训练赛第十八场

题目描述 wls有一个钟表,当前钟表指向了某一个时间. 又有一些很重要的时刻,wls想要在钟表上复现这些时间(并不需要依次复现).我们可以顺时针转动秒针,也可以逆时针转动秒针,分针和时针都会随着秒针按规则转动,wls想知道秒针至少转动多少角度可以使每个时刻至少都会被访问一次. 注意,时钟上的一种时针分针秒针的组合,可以代表两个不同的时间. 输入 第一行一个整数n代表有多少个时刻要访问. 第二行三个整数h,m,s分别代表当前时刻的时分秒. 最后n行每一行三个整数hi,mi,si代表每个要访问的时刻

Contest1828 - 2019年我能变强组队训练赛热身赛

#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1006; const ll mod=1000000007; int T; int n,m; ll k; ll dp[1005][6],a[maxn]; ll gdp[1005][6]; //ll ans; char f[maxn]; int main() { //freopen("1.txt","

2019年第二阶段我要变强个人训练赛第十七场

1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long long ll; 4 const ll mod=1e9+7; 5 const int N=2e6+10; 6 ll c[N],b[N]; 7 ll n,k,a,ans; 8 ll quick(ll a,ll b){ 9 ll res=1; 10 while (b){ 11 if (b&1){ 12 res=res*a%mod; 13 } 14 a=a*a%mo

UPC2018组队训练赛第七场

题目来自ICPC 2017 Japan Tsukuba A题:Secret of Chocolate Poles 有三种巧克力,分别是厚度为1的白色巧克力,厚度为1或者k的黑色巧克力.要求把巧克力放到高度为 l 的盒子里,并且要黑白相间,底部和顶部必须都是黑色的 当l=1,ans=1:当l<k,ans=(l-1)/2+1:当l=k,ans=(l-1)/2+2;当l>k时,就可以转化成排列组合问题了,枚举厚度为k的黑色巧克力数目i,然后对于每一种情况,再枚举厚度为1的黑色巧克力的数目j,那么此时

2018年第四阶段组队训练赛第三场(BAPC2017 Preliminaries)

D.Disastrous Doubling 题目描述 A scientist, E. Collie, is going to do some experiments with bacteria.Right now, she has one bacterium. She already knows that this species of bacteria doubles itself every hour. Hence, after one hour there will be 2 bacter

第四阶段组队训练赛第六场( 题源:UKIEPC2017)

A: Alien Sunset 题目描述 Following tremendous advances in space flight control software and equally impressive innova- tions in reality TV crowdfunding, humans have successfully settled a number of planets, moons, asteroids, and various other kinds of fu

2018年第四阶段组队训练赛第七场

A: Secret of Chocolate Poles 题目描述 Wendy, the master of a chocolate shop, is thinking of displaying poles of chocolate disks in the showcase. She can use three kinds of chocolate disks: white thin disks, dark thin disks, and dark thick disks. The thin