123 456 555 555 123 594 0 0
0 3 1
张洁烽
#include
int main()
{
int a,b,c,d,e,f,n,m,i;
for(;;)
{
scanf("%d%d",&n,&m);
if(n==0&&m==0)
return 0;
else
{
i=0;
a=n/100;b=n%100/10;c=n%10;
d=m/100;e=m%100/10;f=m%10;
if(c+f>=10)
{i+=1;b+=1;}
if(b+e>=10)
{i+=1;a+=1;}
if(a+d>=10)
{i+=1;}
printf("%d\n",i);
}
}
return 0;
}
3 2000 4 5 2001 5 4 2010 10 24
96 124 297
#include
int main()
{
int a,b=0,c,y,m,d,fib;
scanf("%d",&a);
while(a--)
{
scanf("%d %d %d",&y,&m,&d);
if(y%400==0||y%100!=0&&y%4==0)
fib=29;
else fib=28;
for(c=1;c<=m;c++)
switch(c-1)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:b+=31;break;
case 2:b+=fib;break;
case 4:
case 6:
case 9:
case 11:b+=30;break;
}
b+=d;
printf("%d\n",b);
b=0;
}
return 0;
}
有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2 的倍数的开关(这些灯将被关掉),第3 个人按下所有编号为3的倍数的开关(其中关掉的灯将被打开,开着的灯将被关闭),依此类推。一共有k个人,问最后有哪些灯开着?输入:n和k,输出开着的灯编号。k≤n≤1000
7 3
1 5 6 7
#include
using namespace std;
int main()
{
int n,k,a[1000],i;
cin>>n>>k;
for(i=0;i
Tom has many cigarettes. We hypothesized that he has n cigarettes and smokes them
one by one keeping all the butts. Out of k > 1 butts he can roll a new cigarette.
Now,do you know how many cigarettes can Tom has?
3 4 3 10 3 100 5
5 14 124
#include "stdio.h"
#include
int main()
{
//freopen("d:\\1.txt","r",stdin);
//freopen("d:\\2.txt","w",stdout);
int m;
scanf("%d",&m);
while(m--)
{
int n,k,sum;
scanf("%d%d",&n,&k);
sum=n;
while(n/k)
{ sum+=n/k; n=n/k+n%k; }
printf("%d\n",sum);
}
return 0;
}
已知w是一个大于10但不大于1000000的无符号整数,若w是n(n≥2)位的整数,则求出w的后n-1位的数。
4 1023 5923 923 1000
23 923 23 0
#include
int main()
{
int n,m;
scanf("%d",&n);
while(n--)
{
scanf("\n%*c%d",&m);
printf("%d\n",m);
}
}
1 5 10 15 20
200.00
#include
#include
using namespace std;
int main()
{
int n;
cin>>n;
while(n--)
{
int s,a,b,c;
cin>>s>>a>>b>>c;
printf("%.2lf\n",s*a/(double)(b-a)*c);
}
}
2 97 80
A B
#include
using namespace std;
int main()
{
int n,s;
cin>>n;
while(n--)
{
cin>>s;
switch(s/10)
{
case 10:
case 9:cout<<"A"<
3 4 6 7
1 2 3
#include
main(){int n,m,s;scanf("%d",&n);while(n--){scanf("%d",&m);s=0;while(m)m&=m-1,s++;printf("%d\n",s);}}
2 0 0 0 1 0 1 1 0
1.00 1.41
#include
#include
#include
using namespace std;
int main()
{
/*freopen("1.txt","r",stdin);
freopen("2.txt","w",stdout);*/
double x1,x2,y1,y2,m;
double a;
cin>>m;
while(m--)
{
cin>>x1>>y1>>x2>>y2;
a=sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
cout.setf(ios::fixed);
cout<
1/8+3/8 1/4-1/2 1/3-1/3
1/2 -1/4 0
#include
char str[20];
int Gcd(int m,int n)
{
if (m==0) return n;
return Gcd(n%m,m);
}
int main()
{
int fz,fm,gcd;
while(scanf("%s",str)!=EOF)
{
if(str[3]=='-')
fz=(str[0]-'0')*(str[6]-'0')-(str[2]-'0')*(str[4]-'0');
else fz=(str[0]-'0')*(str[6]-'0')+(str[2]-'0')*(str[4]-'0');
if(fz)
{
fm=(str[2]-'0')*(str[6]-'0');
gcd=Gcd(fz,fm);
if(gcd<0) gcd=-gcd;
if(fm/gcd==1) printf("%d\n",fz/gcd);
else printf("%d/%d\n",fz/gcd,fm/gcd);
}
else puts("0");
}
}