2016中国大学生程序设计竞赛 - 网络选拔赛【三水题】
Problem 1001 A water problem
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5832
题意:数能否被137和73整数
解题:大数取余
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long LL;
const int maxn = 10001000;
int n;
char s[maxn];
int main(){
int t = 1;
while(~scanf("%s",s)){
printf("Case #%d: ",t++);
int len = strlen(s);
int ans1 = 0;
int ans2 = 0;
for(int i=0;i<len;i++){
ans1 = (int)((LL) ans1*10+s[i]-'0') % 73;
ans2 = (int)((LL) ans2*10+s[i]-'0') % 137;
}
if(ans1==0 && ans2==0){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}
Problem 1004 Danganronpa
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5835
题意: n种礼物,其量为a[i],要求小朋友收到一神秘礼物和一普通礼物,相邻两个小朋友不能收到相同种类的普通礼物,神秘礼物没限制,问最多收到礼物的小朋友人数。
题解:题目数据有点水,卡了n久,不考虑神秘礼物,就算最多有多少个小朋友可以拿到两件礼物。
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
#include <cmath>
using namespace std;
#define eps 1e-6
#define pi 3.14159265359
typedef long long LL;
typedef long double LD;
const int maxn = 100100;
int t,n,k;
int a[maxn];
int main(){
scanf("%d",&t);
for(int k=1;k<=t;k++){
scanf("%d",&n);
a[0] = 0;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
a[0] += a[i];
}
if(a[0]==1)printf("Case #%d: %d\n",k,1);
else printf("Case #%d: %d\n",k,a[0]/2);
}
return 0;
}
Problem 1011 Lweb and String
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5842
题目:求串的最长 严格递增 子序列的长度
题解:傻逼了我,求不同字母的个数
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define eps 1e-6
#define pi 3.14159265359
typedef long long LL;
const int maxn = 100100;
int n,m,k,t;
char s[maxn];
int main(){
scanf("%d",&t);
for(int k=1;k<=t;k++){
set<char>x;
scanf("%s",s);
n = strlen(s);
for(int i=0;i<n;i++){
x.insert(s[i]);
}
printf("Case #%d: %d\n",k,x.size());
}
return 0;
}