1、P2433 【深基1-2】小学数学 N 合一
#include
#include
#include
#include
int main()
{
int T;
scanf("%d", &T);
if (T == 1)
{
printf("I love Luogu!");
}
else if (T == 2)
{
printf("%d %d", 2+4, 10-2-4);
}
else if (T == 3)
{
printf("%d\n%d\n%d\n", 14/4, (14/4)*4,14%4);
}
else if (T == 4)
{
printf("%.3f",(double)(500.0/3.0));
}
else if (T == 5)
{
printf("%d",(260+220)/(12+20));
}
else if (T == 6)
{
printf("%.4f",sqrt(6*6+9*9));
}
else if (T == 7)
{
printf("%d\n%d\n%d",100+10,100+10-20,0);
}
else if (T == 8)
{
double r=5,p=3.141593,c,s,v;
c=2*p*r;
s=p*r*r;
v=1.0*4/3*p*r*r*r;
printf("%.4f\n%.4f\n%.3f",c,s,v);
}
else if (T == 9)
{
int m=(((1+1)*2+1)*2+1)*2;
printf("%d",m);
}
else if (T == 10)
{
int a=9;
printf("%d",a);
}
else if (T == 11)
{
printf("%.4f",1.0*100/3);
}
else if (T == 12)
{
printf("%d\n%c",'M'-'A'+1,'A'+18-1);
}
else if (T == 13)
{
double pi=3.141593;
printf("%d",(int)(pow(4.0/3*pi*(4*4*4+10*10*10),1.0*1/3)));
}
else if (T == 14)
{
int n=50;
printf("%d",n);
}
return 0;
}
2、P5709 【深基2.习6】Apples Prologue / 苹果和虫子
#include
#include
#include
#include
int main()
{
int m,t,s,n;
scanf("%d %d %d",&m,&t,&s);
if(t==0){printf("0");return 0;}
if(s%t==0)n=m-s/t;
else n=m-s/t-1;
if(n<=0){printf("0");return 0;}
printf("%d",n);
}
3、P5710 【深基3.例2】数的性质
#include
#include
#include
#include
int main()
{
int x;
scanf("%d",&x);
int count=0;
if(x%2==0) count++;
if(x>4&&x<=12)count++;
int a=0,u=0,b=0,z=0;
if(count==0)z=1;
if(count==2)a=1;
if(count>=1)u=1;
if(count==1)b=1;
printf("%d %d %d %d",a,u,b,z);
}
4、P5711 【深基3.例3】闰年判断
#include
#include
#include
#include
int main()
{
int n,t=0;
scanf("%d",&n);
if((n%4==0&&n%100!=0)||(n%400==0&&n%100==0))t=1;
printf("%d",t);
return 0;
}
5、P5712 【深基3.例4】Apples
#include
#include
#include
#include
int main()
{
int n;
scanf("%d", &n);
if (n == 0 || n == 1)
{
printf("Today, I ate %d apple.", n);
}
else
{
printf("Today, I ate %d apples.", n);
}
}
6、P5713 【深基3.例5】洛谷团队系统
#include
#include
#include
#include
int main()
{
int n;
scanf("%d",&n);
if(5*n>11+3*n)printf("Luogu");
else printf("Local");
return 0;
}
7、P5714 【深基3.例7】肥胖问题
#include
#include
#include
#include
int main()
{
double m,h,b;
scanf("%lf %lf",&m,&h);
b=1.0*m/(h*h);
if(b<18.5)printf("Underweight");
if(b>=18.5&&b<24)printf("Normal");
if(b>=24)printf("%.4lf\nOverweight",b);
}
8、P5715 【深基3.例8】三位数排序
#include
#include
#include
#include
int main(){
int a, b, c, t;
scanf("%d%d%d", &a, &b, &c);
if( a > b ){
t = a;
a = b;
b = t;
}
if( a > c){
t = a;
a = c;
c = t;
}
if( b > c ){
t = b;
b = c;
c = t;
}
printf("%d %d %d", a, b, c);
return 0;
}
9、P5716 【深基3.例9】月份天数
#include
#include
#include
#include
int main()
{
int y,m;
int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
scanf("%d %d",&y,&m);
if((y%4==0&&y%100!=0)||(y%400==0&&y%100==0))day[2]=29;
printf("%d",day[m]);
}
10、P1085 [NOIP2004 普及组] 不高兴的津津
#include
#include
#include
#include
int main()
{
int a,b;
int i,j;
int s=0,max=0;
for(i=0;i<7;i++){
scanf("%d %d",&a,&b);
if(a+b>max&&a+b>8) {
max=a+b;
s=i+1;}
}
printf("%d",s);
return 0;
}
11、P1909 [NOIP2016 普及组] 买铅笔
#include
#include
#include
#include
int main()
{
int n;
int a1,a2,a3,b1,b2,b3;
scanf("%d",&n);
scanf("%d %d",&a1,&b1);
scanf("%d %d",&a2,&b2);
scanf("%d %d",&a3,&b3);
//printf("输入成功%d",n);
int c1,c2,c3,d1,d2,d3,d4;
c1=n/a1;
if(n%a1!=0)c1+=1;
d1=b1*c1;
c2=n/a2;
if(n%a2!=0)c2+=1;
d2=b2*c2;
c3=n/a3;
if(n%a3!=0)c3+=1;
d3=b3*c3;
if(d1
12、P5717 【深基3.习8】三角形分类
#include
#include
#include
#include
int main()
{
int a, b, c, t;
scanf("%d %d %d", &a, &b, &c);
if (a > b)
{
t = a;
a = b;
b = t;
}
if (a > c)
{
t = a;
a = c;
c = t;
}
if (b > c)
{
t = b;
b = c;
c = t;
}
if (a + b <=c)
printf("Not triangle\n");
else
{
if (a * a + b * b == c * c)
printf("Right triangle\n");
else if (a * a + b * b > c * c)
printf("Acute triangle\n");
else if (a * a + b * b < c * c)
printf("Obtuse triangle\n");
if (a == b || a == c || b == c)
printf("Isosceles triangle\n");
if (a == b && b == c)
printf("Equilateral triangle\n");
}
}
13、P1422 小玉家的电费
#include
#include
int main()
{int kw;
float cost;
scanf("%d",&kw);
if(kw>=0&&kw<=150)cost=kw*0.4463;
if(kw>=151&&kw<=400)cost=150*0.4463+(kw-150)*0.4663;
if(kw>=401&&kw<=10000)cost=150*0.4463+250*0.4663+(kw-400)*0.5663;
printf("%.1f",cost);
return 0;
}
14、P1424 小鱼的航程(改进版)
这道题用循环很好做,但是一开始看错题目然后修改了一下感觉这样也能写,但是一直有一个样例输出是错的,也不知道是哪里没考虑到,先暂时放上来。(已修改,通过所有样例)
#include
#include
#include
#include
#include
int main(){
int x, n, t;
scanf("%d %d", &x, &n);
if (x != 6 && x != 7)
{
t = (x + n) / 7;
n = n - t * 2;
}
else if(x==7){
x=1;
t = (x + n) / 7;
if(n%7!=0)n = n - t * 2-1;
else n = n - t * 2;
}
else if(x==6){
x=1;
t = (x + n) / 7;
if(n%7!=0)n = n - t * 2-2;
else n = n - t * 2;
}
printf("%d", n * 250);
}
15、P1888 三角函数
#include
#include
#include
#include
int main()
{
int a, b, c;
int t;
scanf("%d %d %d", &a, &b, &c);
if (a > b)
{
t = a;
a = b;
b = t;
}
if (a > c)
{
t = a;
a = c;
c = t;
}
if (b > c)
{
t = b;
b = c;
c = t;
}
if (a == 6 && b == 8 && c == 10)
printf("3/5");
else
printf("%d/%d", a, c);
}
16、P1046 [NOIP2005 普及组] 陶陶摘苹果
#include
#include
#include
#include
int main()
{
int a1,a2,a3,a4,a5,a6,a7,a8,a9,a10;
int h,count=0;
scanf("%d %d %d %d %d %d %d %d %d %d\n%d",&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8,&a9,&a10,&h);
h=h+30;
if(a1<=h)count++;
if(a2<=h)count++;
if(a3<=h)count++;
if(a4<=h)count++;
if(a5<=h)count++;
if(a6<=h)count++;
if(a7<=h)count++;
if(a8<=h)count++;
if(a9<=h)count++;
if(a10<=h)count++;
printf("%d",count);
return 0;
}
17、P4414 [COCI2006-2007#2] ABC
#include
#include
#include
#include
int main()
{
int a,b,c;
char c1,c2,c3;
int t;
scanf("%d %d %d\n",&a,&b,&c);
scanf("%c%c%c",&c1,&c2,&c3);
if((c1b)||(c1>c2&&ac)||(c1>c3&&ac)||(c2>c3&&b
18、P1055 [NOIP2008 普及组] ISBN 号码
#include
#include
#include
#include
int main()
{
char a[14], c1, c2;
int s = 0;
scanf("%c-%c%c%c-%c%c%c%c%c-%c", &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7], &a[8], &a[9], &c1);
int i;
for (i = 1; i <= 9; i++)
{
s += (a[i] - '0') * i;
}
c2 = (s % 11) + '0';
if(c2=='0'+10)c2='X';
if (c1 == c2)
printf("Right");
else
printf("%c-%c%c%c-%c%c%c%c%c-%c", a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], c2);
return 0;
}
基本都是模拟题,有些知识忘了,所以都用的最简单粗暴的方法,代码比较蠢,勉强看看。