Time Limit: 1000 MS Memory Limit: 32768 KB
64-bit integer IO format: %I64d , %I64u Java class name: Main
[Submit] [Status]
35 ON1E2H5Q39AK2TGIC9ERT39B2P423L8B20D
队友敲的,不过后来代码找不到了,,这里就不重打了。。30Min2Y;
E - KFC -Z+W HDU 4147
Time Limit: 1000 MS Memory Limit: 32768 KB
64-bit integer IO format: %I64d , %I64u Java class name: Main
[Submit] [Status]
Description
Welcome to KFC! We love KFC, but we hate the looooooooooong queue. Z is a programmer; he’s got an idea on the queue time computing. Z chooses the shortest queue at first time. He wrote a j2me program to predicate the time he have to wait in the queue. Now, he comes to KFC to test his program. BUT, he ignored some important things to get the precise time. * People choose different foods * Time used on foods various W encountered him just while his wondering on the problem, so he discussed it with HER. W suggested that they can add variables to this * A type ,who is looking down on the cell phone novel should come here alone, will call for 1 hamburger, 1 drink and 1 small fries * B type, two talkative lovers, 1 hamburger and 1 drink for each one and another big fires * C type, middle aged father/mother looks, brings their child out. 3 hamburgers, 3 drinks and two big friezes. Generally represent the types usually appear, not the exactly math work. They reprogram the app on W’s HTC-G1 with bash, run it and go for the fastest queue.Input
Input contains multiple test cases, and for each case: First line: n B D f F, stands for n queues, time for hamburger B, time for Drink D, time for small fries f, time for big Fries F. The next n lines: the types of each line using ABC characters. (1<n,B,D,f,F<=100)Output
For each case, please output the least time to wait in one line.Sample Input
3 2 2 1 2 ABCCBACBCBAB CBCBABBCBA ABCSample Output
31我敲的,其实我5min就发现这是一道简单题,无奈队友在敲别的。。。。35Min1Y(5min就写完了,多简单,第一个写多好!)题意:有A,B,C三种消费模式,问下n列哪个花费最少。代码:#include <iostream> #include <string.h> using namespace std; int main() { int a,b,c,d,e; while(cin>>a>>b>>c>>d>>e) { int mx=100000000; while(a--) { int sum=0; char aa[1000000]; cin>>aa; for(int i=0;i<strlen(aa);i++) { if(aa[i]=='A') { sum+=b+c+d; continue; } else if(aa[i]=='B') { sum+=2*b+2*c+e; continue; } else sum+=3*b+3*c+2*e; } if(sum<mx) { mx=sum; } } cout<<mx<<endl; } }H - Powerful IncantationHDU 4150
Time Limit: 2000 MS Memory Limit: 32768 KB
64-bit integer IO format: %I64d , %I64u Java class name: Main
[Submit] [Status]
Description
Some dangerous Witches invaded the garden city! As a righteous magician, james0zan want to find the most powerful incantation so he can beat those dangerous witches easily. After consulted one hundred and eight thousand Magic Books, james0zan find a way to calculate the power of an incantation. There is a very short incantation called “magic index” which contains the magic power, and each incantation’s power can be calculated by the times the “magic index” appearance in the incantation. Notice that if two “magic index” overlapped, the power only should be calculated once. And we just want the incantation more powerful. That is to say, if the “magic index” is “aa”, the power of incantation “aaaa” is 2(“aa”+”aa”), not 1(“a”+”aa”+”a”) or 3.Input
The first line is an integer t (t<=30), the number of test cases. Each of the next t lines contains two strings, represent the incantation (length<=10^6) and the “magic index” (length<=5). Every char in the incantation and the magic index is lowercase.Output
For each test case you should output the power of the incantation.Sample Input
3 aaaa aa bsdjfassdiifo sd papapapapapapap apSample Output
2 2 769Min2Y;竟然超时了,队友把输入输出流改了就过了。。。。。题意:问前串有多少个后子串#include<stdio.h> #include<string.h> int main() { int t; scanf("%d",&t); while(t--) { int sum=0; int j,i,k; char a[1000001]; char b[6]; scanf("%s",a); scanf("%s",b); for(i=0; a[i]!=0; i++) { int k=0; int flag=1; for(j=i; b[k]!=0; j++) { if(a[j]!=b[k++])flag=0;; } if(flag) { i+=k-1; sum++; } } printf("%d\n",sum); }}I - The Special Number HDU 4151
Time Limit: 1000 MS Memory Limit: 32768 KB
64-bit integer IO format: %I64d , %I64u Java class name: Main
[Submit] [Status]
Description
In this problem, we assume the positive integer with the following properties are called ‘the special number’: 1) The special number is a non-negative integer without any leading zero. 2) The numbers in every digit of the special number is unique ,in decimal system. Of course,it is easy to check whether one integer is a ‘special number’ or not, for instances, 1532 is the ‘special number’ and 101 is not. However, we just want to know the quantity of the special numbers that is less than N in this problem.Input
The input will consist of a series of signed integers which are not bigger than 10,000,000. one integer per line. (You may assume that there are no more than 20000 test cases)Output
For each case, output the quantity of the special numbers that is less than N in a single line.Sample Input
10 12Sample Output
9 10队友打的表,表出来了很开心,结果翻译翻译成输出小于n的最大the special number’数,样例恰巧是一样的。。。。贡献了2发WA。各个位都不相同的数被称为'the special number’,问小于n的the special number’的个数。136Min3Y;代码:#include <stdio.h> #include <stdlib.h> int shu[712891]; int main() { int a,b,c,d,e,f,g,temp,he=0; for(a=0; a<=9; a++) { for(b=0; b<=9; b++) { if(b!=0) { if(b==a)continue; } for(c=0; c<=9; c++) { if(c==0) { if(a!=0) { if(b==0)continue; } } if(c!=0) { if(c==a)continue; if(c==b)continue; } for(d=0; d<=9; d++) { if(d==0) { if(a!=0) { if(b==0)continue; if(c==0)continue; } else if(b!=0) { if(c==0)continue; } } if(d!=0) { if(d==a)continue; if(d==b)continue; if(d==c)continue; } for(e=0; e<=9; e++) { if(e==0) { if(a!=0) { if(b==0)continue; if(c==0)continue; if(d==0)continue; } else if(b!=0) { if(c==0)continue; if(d==0)continue; } else if(c!=0) { if(d==0)continue; } } if(e!=0) { if(e==a)continue; if(e==b)continue; if(e==c)continue; if(e==d)continue; } for(f=0; f<=9; f++) { if(f==0) { if(a!=0) { if(b==0)continue; if(c==0)continue; if(d==0)continue; if(e==0)continue; } else if(b!=0) { if(c==0)continue; if(d==0)continue; if(e==0)continue; } else if(c!=0) { if(d==0)continue; if(e==0)continue; } else if(d!=0) { if(e==0)continue; } } if(f!=0) { if(f==a)continue; if(f==b)continue; if(f==c)continue; if(f==d)continue; if(f==e)continue; } for(g=0; g<=9; g++) { if(g==0) { if(a!=0) { if(b==0)continue; if(c==0)continue; if(d==0)continue; if(e==0)continue; if(f==0)continue; } else if(b!=0) { if(c==0)continue; if(d==0)continue; if(f==0)continue; if(e==0)continue; if(f==0)continue; } else if(c!=0) { if(d==0)continue; if(e==0)continue; if(f==0)continue; } else if(d!=0) { if(e==0)continue; if(f==0)continue; } else if(e!=0) { if(f==0)continue; } } if(g!=0) { if(g==a)continue; if(g==b)continue; if(g==c)continue; if(g==d)continue; if(g==e)continue; if(g==f)continue; } temp=a*1000000+b*100000+c*10000+d*1000+e*100+f*10+g; shu[he++]=temp; } } } } } } } int qwe; while(~scanf("%d",&qwe)) { int mx=0; int ii; for(ii=1;ii<712891;ii++) { if(shu[ii]<qwe) { mx++; } else break; } printf("%d\n",mx); } }A - A Simple Problem HDU 4143
Time Limit: 1000 MS Memory Limit: 32768 KB
64-bit integer IO format: %I64d , %I64u Java class name: Main
[Submit] [Status]
Description
For a given positive integer n, please find the smallest positive integer x that we can find an integer y such that y^2 = n +x^2.Input
The first line is an integer T, which is the the number of cases. Then T line followed each containing an integer n (1<=n <= 10^9).Output
For each integer n, please print output the x in a single line, if x does not exit , print -1 instead.Sample Input
2 2 3Sample Output
-1 1 对于每个n,求出最小的x,没有输出-1. 256Min2Y。题解:y^2=n+x^2,整理得:(y+x)*(y-x)=n.设y+x=a,y-x=b,则x=(a-b)/2;这里a,b是n的因子,要想x最小,则a-b最小,所以从n的最大因子开始找,for(int a=sqrt(n); a>=1; a--) { if(n%a==0)//保证b是整数。 { int b=a/i; double x=(b-i)/2.0; if((int)x==x&&x>0)//x也得是整数,而且x得大于0。代码:#include <math.h> #include <stdio.h> int main() { int t,a; scanf("%d",&t); while(t--) { scanf("%d",&a); int mx=-1; for(int i=sqrt(a); i>=1; i--) { if(a%i==0) { int b=a/i; double x=(b-i)/2.0; if((int)x==x&&x>0) { mx=x; break; } } } printf("%d\n",mx); } }