zoukankan      html  css  js  c++  java
  • Codeforces Round #634 (Div. 3)

    A

    题目链接:http://codeforces.com/contest/1335

    思路:简单的推理:

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    int main()
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
                ll a;
                scanf("%lld",&a);
                if(a<=2)
                    printf("0
    ");
                else if(a%2==0)
                    printf("%lld
    ",a/2-1);
                else
                    printf("%lld
    ",a/2);
        }
    
        return 0;
    }
    

      B

    思路:逐位考虑,保持循环即可,字符串拥有循环节

    //-------------------------------------------------
    //Created by HanJinyu
    //Created Time :三  4/15 23:10:31 2020
    //File Name :cf3B.cpp
    //-------------------------------------------------
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    #define long long ll
    #define double db
    #define maxn 200005
    using namespace std;
    void disp(int a,int b)
    {
        for(int i=1;i<=a/b;i++)
        {
            for(int j=0;j<b;j++)
            {
                printf("%c",97+j);
            }
        }
        for(int i=0;i<a%b;i++)
            printf("%c",97+i);
    
    }
    int main()
    {
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        int T;
        scanf("%d",&T);
        while(T--)
        {
            int n,a,b;
            scanf("%d%d%d",&n,&a,&b);
            int num=n/a;
            int num1=n%a;
            for(int k=0;k<num;k++)
                disp(a,b);
            int ops=0;
            for(int t=a%b;t<a%b+num1;t++)
            {
                if(t>=b)
                {
                    break;
                }
                else{
                     ops++;
                     printf("%c",97+t);
                }
    
            }
            if(num1-ops<=b){
    
            for(int i=0;i<(num1-ops);i++)
                printf("%c",97+i);
    
            }
            else
                disp(num1-ops,b);
            printf("
    ");
        }
         return 0;
    }
    

      c

    思路:比较数字出现的最多次数那个数字的次数和数组不同的个数,输出最小的即可

    //
    // Created by H on 2020/4/13.
    //
    
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int t;
        scanf("%d",&t);
        while(t--)
        {
            map<int,int>ap;
            int n;
            scanf("%d",&n);
            int mm;
            for(int i=0;i<n;i++)
            {
                scanf("%d",&mm);
                ap[mm]++;
            }
            int cishu=0;
            for(auto v:ap)
            {
                cishu=max(cishu,v.second);
            }
            if(ap.size()==cishu)
                cout<<cishu-1<<endl;
            if(ap.size()>cishu)
                cout<<cishu<<endl;
            if(ap.size()<cishu)
                cout<<ap.size()<<endl;
        }
        return 0;
    }
    

      D

    思路:数独,只要任意将一个数变成另外一个数即可

    //-------------------------------------------------
    //Created by HanJinyu
    //Created Time :四  4/16 13:35:36 2020
    //File Name :shudu.cpp
    //-------------------------------------------------
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    #define long long ll
    #define double db
    #define maxn 200005
    using namespace std;
    
    int main()
    {
        //freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
        int t;
        scanf("%d",&t);
        while(t--)
        {
            char ch[10][10];
            for(int i=0;i<9;i++)
            {
    
                for(int j=0;j<9;j++)
                    {
    
                        cin>>ch[i][j];
                        if(ch[i][j]=='1')
                            ch[i][j]='2';
                    }
            }
            for(int i=0;i<9;i++)
            {
    
                for(int j=0;j<9;j++)
                {
    
                    cout<<ch[i][j];
                }
                cout<<endl;
            }
        }
     
         return 0;
    }
    

      

  • 相关阅读:
    POJ1486 Sorting Slides 二分图or贪心
    POJ2060 Taxi Cab Scheme 最小路径覆盖
    POJ3083 Children of the Candy Corn 解题报告
    以前的文章
    POJ2449 Remmarguts' Date K短路经典题
    这一年的acm路
    POJ3014 Asteroids 最小点覆盖
    POJ2594 Treasure Exploration 最小路径覆盖
    POJ3009 Curling 2.0 解题报告
    POJ2226 Muddy Fields 最小点集覆盖
  • 原文地址:https://www.cnblogs.com/Vampire6/p/12712388.html
Copyright © 2011-2022 走看看