zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 77 (Rated for Div. 2)

    A:

    尽可能平均然后剩下的平摊

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int maxx=2;
    int n,m,a,b;
    int read(){
        char c=getchar();int x=0,f=1;
        while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
        return x*f;
    }
    int main()
    {
        n=read();
        while(n--){
            ll kk,kkk,res;
            a=read(),b=read();
            kk=b/a;
            kkk=b%a;
            b%=a;
            res=(a-kkk)*(kk*kk);
            res+=kkk*(kk+1)*(kk+1);
            printf("%lld\n",res);
        }
        return 0;
    }
    

    B 

    逆着思维从0开始操作,会发现两边加起来肯定是3*(k+x+y+...),然后在保证下最小的数起码得大于x+y+z...就行

    #include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int maxx=2;
    ll n,m;
    ll a,b;
    ll mi;
    ll read(){
        char c=getchar();ll x=0,f=1;
        while(c<'0'||c>'9'){if(c=='-')f=-1; c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0'; c=getchar();}
        return x*f;
    }
    int main()
    {
        n=read();
        while(n--){
            a=read(),b=read();
            mi=min(a,b);
            if((a==1&&b==1)||(a==2&&b==2)){puts("NO");continue;}
            ll ans=a+b;
            if(ans%3==0){
                if((ans/3)>mi){puts("NO");continue;}
                else {puts("YES");continue;}
            }
            else puts("NO");
        }
        return 0;
    }
    

     c

    有一个超长围栏

    l r

    从0开始,第i块板下标是l的倍数,刷红色,是r的倍数,刷蓝色,同时是l,r的倍数,红蓝都可以。

    然后有颜色的板子连起来,如果有k个板子的颜色一模一样,你就死定了。

            // In God We Trust
    
    
    # include <bits/stdc++.h>
    using namespace std;
    
    # define INF 1 << 31 - 1
    # define pb push_back
    # define fi first
    # define se second
    
    int gcd(int a, int b)
    {
        // Everything divides 0
        if (a == 0)
           return b;
        if (b == 0)
           return a;
    
        // base case
        if (a == b)
            return a;
    
        // a is greater
        if (a > b)
            return gcd(a % b, b);
        return gcd(a, b % a);
    }
    
    
    signed main() {
      cout<<__gcd(8,12);
      int t;
      cin >> t;
      int r, b, k;
      for (int i = 0; i <t; i++){
        cin >> r >> b >> k;
        if ( r == b ){
          cout << "obey" << endl ;
          continue;
        }
        int g = gcd(r, b);
        int n = max(r, b) / g;
        int m = min(r, b) / g;///简化
        int l = n / m;
        if (m == 1)///模拟一下就知道为什么
          l --;
        else if (n % m != 1)///我们可以理解为,n到2n,2n到3n,3n到4n。。。。等于1相当于某一段n的区间内m的倍数接下来下一个数字就是n,之间没有多出一个数字,也就是说如果不等于1,中间空出来几个数字会提供m的倍数几个位置导致在下一段的n区间内,第一个m的倍数字可以前移了,那么肯定是可以再提供一个数字的在此区间里!!
          l ++;
        if (l < k)
          cout << "obey" << endl;
        else
          cout << "rebel" << endl;
      }
    
    }
    

      

  • 相关阅读:
    十大排序算法
    SQL优化指南
    Python基础-类与对象
    Python基础-函数
    Python基础-字典
    Python基础-字符串
    Python基础-列表
    以太坊智能合约开发框架Truffle
    比特币钱包搭建与使用
    矩阵的压缩存储
  • 原文地址:https://www.cnblogs.com/hgangang/p/11949643.html
Copyright © 2011-2022 走看看