![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT (Basic Level) Practise
shannonchao
这个作者很懒,什么都没留下…
展开
-
1001. 害死人不偿命的(3n+1)猜想 (15)
400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, Yue卡拉兹(Callatz)猜想:对任何一个自然数n,如果它是偶数,那么把它砍掉一半;如果它是奇数,那么把(3n+1)砍掉一半。这样一直反复砍下去,最后一定在某一步得原创 2015-02-04 14:32:58 · 322 阅读 · 0 评论 -
1014. 福尔摩斯的约会 (20)
#include#include#includeusing namespace std;int main(){ int k=0; string str1,str2,str3,str4; cin>>str1>>str2>>str3>>str4; for(int i=0;i<str1.length(),i<str2.length();i++) { if(str1[i]==s原创 2015-02-06 20:03:46 · 494 阅读 · 0 评论 -
1015. 德才论 (25)
用cin、cout超时……#include#include#includeusing namespace std;struct stu{ int id; int de; int cai; };bool greater_sco(stu s1,stu s2){ if(s1.de+s1.cai!=s2.cai+s2.de) return (s1.cai+s1.de)原创 2015-02-06 20:07:41 · 318 阅读 · 0 评论 -
1017. A除以B (20)
#include#includeusing namespace std;int main(){ string str; int n,temp=0,flag=1; cin>>str>>n; for(int i=0;i<str.length();i++) { temp = temp*10+str[i]-48; if(temp>=n) { printf("%d",te原创 2015-02-10 21:14:08 · 279 阅读 · 0 评论 -
1022. D进制的A+B (20)
#include#includeusing namespace std;int main(){ unsigned long long A,B; int D,i; stack s; cin>>A>>B>>D; A=A+B; if(D==10) { cout<<A<<endl; } else if(A==0) { cout<<0<<endl; } else {原创 2015-02-11 20:14:12 · 313 阅读 · 0 评论 -
1016. 部分A+B (15)
#include#includeusing namespace std;int main(){ int A,B,DA,DB,sum=0; scanf("%d%d%d%d",&A,&DA,&B,&DB); int i=0; do{ if(A%10==DA) { sum+=DA*pow(10.0,i); i++; } A/=10; }while(A!=0)原创 2015-02-10 21:05:26 · 285 阅读 · 0 评论 -
1018. 锤子剪刀布 (20)
#includeusing namespace std;int main(){ int n,i; int s1=0,f1=0,p1=0,s2=0,f2=0,p2=0,c1=0,j1=0,b1=0,c2=0,j2=0,b2=0; char a,b,max1,max2; scanf("%d",&n); for(i=0;i<n;i++) { cin>>a>>b; if(a==原创 2015-02-11 18:49:28 · 350 阅读 · 0 评论 -
1021. 个位数统计 (15)
#include#includeusing namespace std;int main(){ int count[10]={0},i; string num; cin>>num; string::iterator it; for(it=num.begin();it!=num.end();it++) { count[(*it-'0')]++; } for(i=0;i<原创 2015-02-11 20:09:19 · 270 阅读 · 0 评论 -
1019. 数字黑洞 (20)
#include#includeusing namespace std;static int a,b;void arrange(int n){ int temp[4]; temp[0]=n/1000; temp[1]=n/100%10; temp[2]=n/10%10; temp[3]=n%10; sort(temp,temp+4); a=temp[0]*1000+tem原创 2015-02-11 19:16:29 · 328 阅读 · 0 评论 -
1020. 月饼 (25)
#include#includeusing namespace std;struct mp{ //包含每种月饼的数量总价单价 float num; float tot; float pri;} pie[1001];bool greater_pri(mp pie1,mp pie2) //根据单价降序排序{ return pie1.pri>pie2.pri原创 2015-02-11 19:19:12 · 662 阅读 · 0 评论 -
1013. 数素数 (20)
#include #include using namespace std;int isprime(int n){ int i; for(i=2;i if(n%i==0) return 0; return 1;}int main(){ int i=2,j=0,n,m,k=0;原创 2015-02-06 19:52:36 · 2929 阅读 · 1 评论 -
1011. A+B和C (15)
#includeusing namespace std;int main(){ int n,i; long long A,B,C; cin>>n; for(i=0;i<n;i++) { cin>>A; cin>>B; cin>>C; if(A+B>C) cout<<"Case #"<<i+1<<": true"<<endl; else cout<<原创 2015-02-06 19:31:02 · 272 阅读 · 0 评论 -
1012. 数字分类 (20)
#include#includeusing namespace std;int main(){ int n,i,temp,a1=0,a2=0,flag2=0,flag22=0,a3=0,a4=0,flag4=0,a5=0; cin>>n; for(i=0;i<n;i++) { cin>>temp; if(temp/10*10==temp) a1+=temp; if原创 2015-02-06 19:35:50 · 272 阅读 · 0 评论 -
1003. 我要通过!(20)
时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者原创 2015-02-04 19:04:34 · 293 阅读 · 0 评论 -
1002. 写出这个数 (20)
#include #include #include using namespace std;int main(){ int n=0; char ch; string st; stack s; bool flag = false; while((ch=cin.get())!='\n') { n+=ch-'0'; } while(n)原创 2015-02-04 14:38:41 · 15914 阅读 · 0 评论 -
1004. 成绩排名 (20)
#include#includeusing namespace std;int main(){ struct item { string name; string numb; int sco; }; item maxs,mins,temp; int n; cin>>n>>maxs.name>>maxs.numb>>maxs.sco; mins原创 2015-02-04 19:14:08 · 328 阅读 · 0 评论 -
1005. 继续(3n+1)猜想 (25)
#includeusing namespace std;void msort(int num[100],int n){ int i,j,k; for(i=1;i<n;i++) { k=num[i]; j=i-1; while(j!=-1&&k<num[j]) { num[j+1]=num[j]; j--; } num[j+1]=原创 2015-02-05 13:30:15 · 392 阅读 · 0 评论 -
1008. 数组元素循环右移问题 (20)
#includeusing namespace std;int main(){ int n,k,a[101],i,flag=1; cin>>n; cin>>k; k=k%n; for(i=0;i<n;i++) { cin>>a[i]; } for(i=0;i<k;i++) { if(flag==1) flag=0; else cout<<" ";原创 2015-02-05 19:09:04 · 308 阅读 · 0 评论 -
1010. 一元多项式求导 (25)
#includeusing namespace std;int main(){ int flag=1,tag=1,m,n,sum; while(cin>>m){ if(m == 0) break; if(tag){ n = m; tag = 0; }原创 2015-02-05 19:22:35 · 450 阅读 · 0 评论 -
1006. 换个格式输出整数 (15)
#includeusing namespace std;int main(){ int n,i,temp; cin>>n; temp=n/100; for(i=1;i<=temp;i++) { cout<<"B"; } temp=n%100/10; for(i=1;i<=temp;i++) { cout<<"S"; } temp=n%10; for(i=原创 2015-02-05 18:51:38 · 234 阅读 · 0 评论 -
1007. 素数对猜想 (20)
#include #include using namespace std;bool isprime(int n){ int i; for(i=2;i<=(int)sqrt((double)n);i++) if(n%i==0) return 0; return 1; }int twinprime(int n){ if(n==1||n==2||n==3||n==4原创 2015-02-05 19:02:43 · 337 阅读 · 0 评论 -
1009. 说反话 (20)
#include#include#includeusing namespace std;int main(){ int flag = 0; string sp; stack s; while(cin>>sp) s.push(sp); while(!s.empty()) { if(flag) cout<<" "; else flag=1;原创 2015-02-05 19:18:35 · 266 阅读 · 0 评论 -
1023. 组个最小数 (20)
#includeusing namespace std;int main(){ int a[10],i,j,k; for(i=0;i<10;i++) { cin>>a[i]; } for(i=1;i<10;i++) { if(a[i]!=0) break; } cout<<i; a[i]--; for(j=0;j<10;j++) { if(a[j])原创 2015-02-11 20:25:13 · 345 阅读 · 0 评论