2016-CCPC网络赛(2/10)

A题

一个星球一年有73天,另外一个一年有137天,现在给你第n天,你判断这一天是不是同时是两个星球的一年中的第一天
问n是不是同时整除73和137,但是n超大,用到紫书的大数模去一个较小的数的方法

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
char n[10000010];
int m;
int main(){
    int m = 10001;
    int cas = 1;
    while(~scanf("%s",n)){
        int len = strlen(n);
        int ans = 0;
        for(int i=0;i < len;i++){
            ans = (int)(((long long)ans*10+n[i]-'0')%m);
        }
        printf("Case #%d: ",cas++);
        if (ans == 0) printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

B题

C题

D题

E题

F题

G题

H题

I题

J题

K题

给你一个字符串,然后你可以定义一个字母对应一个数,问你最长严格递增子序列长度
因为是严格递增的,所以对于字符串str,答案最大为str中所有字符去重后的数目,然后按照顺序递增对应,就是递增的,所有答案就是str中去重后字符的个数

#include <cstdio>
#include <set>
#include <iostream>
#include <string>
using namespace std;
string str;
set<char> myset;
int main(){
	int t;scanf("%d",&t);
	int cas = 1;
	while(t--){
		myset.clear();
		cin>>str;
		for(int i = 0;i < str.length();i++){
			myset.insert(str[i]);
		}
		printf("Case #%d: %d\n",cas++,myset.size());
	}
	return 0;
} 
发布了27 篇原创文章 · 获赞 0 · 访问量 351

猜你喜欢

转载自blog.csdn.net/weixin_44083561/article/details/104078420
今日推荐