- 博客(31)
- 收藏
- 关注
原创 O - Vanya and Cubes()
#include<bits/stdc++.h>using namespace std;int main(){ int n,i,sum,k,j; scanf("%d",&n); sum=0; for(i=1;;i++) { k=0; for(j=1;j<=i;j++) { k+=j; } sum+=k; if(sum>n) break; } printf("%d\n",i-1); return 0;}
2021-01-30 21:44:19 76
原创 P - Game With Sticks(棍子游戏)
#include<bits/stdc++.h>using namespace std;int main(){ int n,m,minn; cin>>n>>m; minn=min(n,m); if(minn%2==0) cout<<"Malvika"<<endl; else cout<<"Akshat"<<endl; return 0;}//一定要多画图啊,2,4,就是一个特别的例子,要不...
2021-01-30 21:37:05 171
原创 A - Cards for Friends
#include <stdio.h>int main(){ int i,j,w,h,n,x,m; scanf("%d",&m); while(~scanf("%d%d%d",&w,&h,&n)) { x=1; for(i=2;w%i==0;i=i*2) x=x*2; for(i=2;h%i==0;i=i*2) x=x*2; if(n>x)...
2021-01-29 17:15:02 154
原创 B - Fair Division
#include<stdio.h>int main(){ int t,n,a,b,i,c[100]; scanf("%d",&t); while(~scanf("%d",&n)) { a=0;b=0; for(i=1;i<=n;i++) { scanf("%d",&c[i]); if(c[i]==1) a++; else b++; } if(b%2==0)...
2021-01-29 16:05:30 137
原创 C - Maximum GCD(最大公约数)
#include <stdio.h>#include <math.h>int main(){ int n,m,t,a[100],k,i,j,c; scanf("%d",&m); while(~scanf("%d",&n)) { printf("%d\n",n/2); } return 0;}//这个直截了当的思路刚开始真的是没想到啊...
2021-01-29 15:55:34 145
原创 D - Four Segments
Monocarp wants to draw four line segments on a sheet of paper. He wants the ii-th segment to have its length equal to aiai (1≤i≤41≤i≤4). These segments can intersect with each other, and each segment should be either horizontal or vertical.Monocarp wants
2021-01-29 15:40:42 143
原创 E - New Year Candles
Vasily the Programmer loves romance, so this year he decided to illuminate his room with candles.Vasily has a candles.When Vasily lights up a new candle, it first burns for an hour and then it goes out. Vasily is smart, so he can make b went out candles i
2021-01-29 15:34:38 78
原创 F - The New Year: Meeting Friends
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to me
2021-01-29 15:03:41 55
原创 G - Again Twenty Five!(最后25)
The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. “Do I give such a hard task?” — the HR manager thought. “Just raise number 5 to the power of n and get last two digits of the number. Yes, of c
2021-01-29 13:34:38 188
原创 H - Fence(连续k个数之和最小)
#include<stdio.h>int main() { int n,m,j,c,a[500000],min,i,sum,k; scanf("%d%d",&n,&k); for(i=1;i<=n;i++) { scanf("%d",&a[i]); } sum=0; for(i=1;i<=k;i++) sum+=a[i];//前k个数之和 min=sum;...
2021-01-29 13:28:36 97
原创 N - Odd Divisor(判断是否有大于1的奇数公约数)
You are given an integer nn. Check if nn has an odd divisor, greater than one (does there exist such a number xx (x>1x>1) that nn is divisible by xx and xx is odd).For example, if n=6n=6, then there is x=3x=3. If n=4n=4, then such a number does not
2021-01-29 13:00:36 431
原创 M - String LCM(LCM字符串)
Let’s define a multiplication operation between a string aa and a positive integer xx: a⋅xa⋅x is the string that is a result of writing xx copies of aa one after another. For example, “abc” ⋅ 2 =⋅ 2 = “abcabc”, “a” ⋅ 5 =⋅ 5 = “aaaaa”.A string aa is divisi
2021-01-29 12:54:22 355 1
原创 L - Regular Bracket Sequence(括号序列)
A bracket sequence is called regular if it is possible to obtain correct arithmetic expression by inserting characters + and 1 into this sequence. For example, sequences (())(), () and (()(())) are regular, while )(, (() and (()))( are not. Let’s call a re
2021-01-27 22:23:11 272
原创 面板暂停 Wizard of Orz
#include<stdio.h>int main(){ int i,n,s,s1,j,t,min; scanf("%d",&t); while(t--) { scanf("%d",&n); if(n==1) printf("9\n"); if(n==2) printf("98\n"); if(n==3) printf("989\n"); if(n>3) { printf("989"); int k=0...
2021-01-27 22:11:24 100
原创 red and blue
#include<cstdio>#include<algorithm>using namespace std;int main(){ int n,a,m,t,sum1,sum2; scanf("%d",&n); while(n--) { a=0;m=0;sum1=0;sum2=0; scanf("%d",&t); while(t--) { ...
2021-01-27 14:41:42 125
原创 strange list
I - Red and BlueMonocarp had a sequence aa consisting of n+mn+m integers a1,a2,…,an+ma1,a2,…,an+m. He painted the elements into two colors, red and blue; nn elements were painted red, all other mm elements were painted blue.After painting the elements, h
2021-01-27 12:26:31 141
原创 (贪心问题)今年暑假不AC
#include<stdio.h>int main(){ int i,n,s,s1,j,t,min; int a[100],b[100]; while(~scanf("%d",&n)) { if(n==0) break; for(i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]); for(i=1;i<=n;i++) { for(j...
2021-01-25 22:32:02 133
原创 (递推)阿牛的EOF牛肉串
#include<stdio.h>int main(){ int i,n,s,s1,j; long long a[55]; a[1]=3;a[2]=8; for(i=3;i<=41;i++) a[i]=2*(a[i-1]+a[i-2]); while(~scanf("%d",&n)) { printf("%lld\n",a[n]); } return 0;}//在输入n之前就把数据计算储存好,这样在输出时节省时间 //考虑第n个位置是O还..
2021-01-25 16:52:16 128
原创 对于输入的每个字符串,查找其中的最大字母,在该字母后面加字符串“(max)”
#include<stdio.h>#include<string.h> int main() { int i; char a[100],max; while(~scanf("%s",a)) { max=a[0]; for(i=1;a[i]!='\0';i++) { if(a[i]>max) max=a[i]; } for(i=0;a[i]!='\0';i++) { if(a[i]!=max)..
2021-01-24 20:45:33 2588
原创 首字母变大写
#include<stdio.h>#include<string.h> int main() { int n,i,j,k,b,c,d,x,y; char a[100]; while(gets(a))//多组输入字符串 { if(a[0]>='a'&&a[0]<='z')//特殊位置单独讨论对第一个 a[0]=a[0]-32; for(i=0;i<strlen(a);i++) { .
2021-01-24 20:15:18 56 1
原创 统计元音在字符串中出现的的次数
#include<stdio.h>#include<string.h> int main() { int n,i,j,k,b,c,d,x,y; char a[100]; while(~scanf("%d",&n)) { getchar();//吸收n后的空格 while(n--) { gets(a);//输入字符串, b=0;c=0;d=0;x=0;y=0; for(i=0;a[i]!='..
2021-01-24 20:06:06 534
原创 求n个数的最小公倍数
#include<stdio.h>int main() { int multiple(int a,int b);//调用求最小公倍数的最小函数 int j,n,s,i,a[10000]; while(~scanf("%d",&n)) { for(j=0;j<n;j++) scanf("%d",&a[j]); if(n==1) printf("%d\n",a[0]); else { s=m.
2021-01-24 19:49:36 222
原创 人见人爱A+B
#include<stdio.h>int main() { int n,i,j,s,x,y,z,a[10000]; scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=6;j++) { scanf("%d",&a[j]); s=(a[1]+a[4])*3600+(a[2]+a[5])*60+a[3]+a[6]; x=s/3600; y..
2021-01-24 19:00:54 140 1
原创 求a^b的最后三位数表示的整数
#include<stdio.h>int main() { long long s; int a,b,i; while(~scanf("%d%d",&a,&b)) { if(a==0&&b==0) break; s=1; for(i=1;i<=b;i++) { s=s*a%1000; //由于随着次幂的增加,数会越来越大,所以要时刻只保留三位数以下 } prin..
2021-01-24 18:19:14 294
原创 给定三边长,判断能否组成三角形
#include<stdio.h>int main() { double a,b,c; int n; scanf("%d",&n); while(n--) { scanf("%lf%lf%lf",&a,&b,&c); if(a+b>c&&a+c>b&&b+c>a) printf("YES\n"); else printf("NO\n");.
2021-01-24 18:09:38 394
原创 给你一个密码,判断是否为安全密码
#include<stdio.h>#include<string.h> int main(){ int i,n,x,y,z,h; char a[100]; scanf("%d",&n); getchar();//吸收字符 while(n--) { scanf("%s",a); x=0;y=0;z=0;h=0; for(i=0;i<strlen(a);i++) { if(a[i]>='0'&&a[i]<..
2021-01-24 18:01:12 745
原创 一只蜜蜂只能爬右侧相邻的蜂房,不能反向爬行,编程计算蜜蜂从a到b的可能路线(递推)
#include<stdio.h>int main(){ int i,n,m,c,b; long long a[55];//斐波那契数列的特点之一是数字剧增 scanf("%d",&n);while(~scanf("%d%d",&c,&b)){ a[0]=0; a[1]=1; a[2]=2; for(i=3;i<=b;i++) { a[i]=a[i-1]+a[i-2]; } printf("%lld\n",a[b-c]);}..
2021-01-24 17:26:29 2290 5
原创 (递推)有一楼梯共m级,刚开始你在第一层,若每次只能上一级或二级,要走上第m级,共有多少走法(递推)
#include<stdio.h>int main(){ int i,n,m,a[45]; scanf("%d",&n);while(~scanf("%d",&m)){ a[1]=0; a[2]=1; a[3]=2; for(i=4;i<=m;i++) { a[i]=a[i-1]+a[i-2]; } printf("%d\n",a[m]);} return 0;}//考察递推问题a3=a1+a2;
2021-01-24 16:20:25 1532
原创 亲和数
在这里插入图片描述#include <stdio.h>int main(){ int n,m,k,i,j,a,b,sum1,sum2; scanf("%d",&m); while(~scanf("%d%d",&a,&b)) { sum1=0; sum2=0; for(i=1;i<a;i++)//找a的所有真约数 { if(a%i==0) sum1+=i; } for(j=1
2021-01-22 15:15:22 113
原创 处理集合A-B
在这里插入图片描述#include <stdio.h>int main(){ int i,j,m,n,a[1000],s,t,b[1000],k,h; while(~scanf("%d%d",&n,&m)) { if(n==0&&m==0) break; for(i=0;i<n+m;i++) scanf("%d",&b[i]); for(i=0;i<n-1;i++)//对集合A进行排序 { for
2021-01-22 14:45:36 665
原创 知道多边形各点的坐标,求多边形面积
在这里插入图片描述#include <stdio.h>#include <math.h>//已知多边形各点坐标,求多边形面积int main(){ int n,i,x1,x2,x3,y1,y2,y3,a[100],b[100]; double s; while(~scanf("%d",&n)) { if(n==0) break; for(i=1;i<=n;i++) scanf("%d%d",&..
2021-01-21 15:48:06 1150
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人