![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
codeforces
ScorpioN___
这个作者很懒,什么都没留下…
展开
-
Codeforces 778B. Weird Rounding
题意:给你一个数,可以随意删除这个数的每一位,最少删几位是使剩下的数能被10的k次方整除。思路:就是判断数中有几个0,如果数量大于等于k,就随便删除使数的后k位都为0;如果数量小于k,那就删len-1个数,只留一个0.#includeusing namespace std;char str[15];int main(){ int k,sum,sum1; while(原创 2017-02-28 21:31:30 · 435 阅读 · 0 评论 -
749 C. Voting codeforces
思路:每一个D(或者R)都会消除下一个离他最近的R(D),以此类推,谁先为0,谁就输,根据这个进行模拟。 #include using namespace std; char str[200005]; bool visit[200005]; int main() { int n,numd=0,numr=0; scanf("%d%s",&n,str);原创 2016-12-22 17:19:46 · 469 阅读 · 0 评论 -
749 B. Parallelogram is Back codeforces
#includeusing namespace std;struct node{ int x; int y;}arr[5],arr1[5],arr2[5];int main(){ for(int i=1;i<=3;i++) cin>>arr[i].x>>arr[i].y; int sum=0,visit[5]; memset(vi原创 2016-12-22 17:15:38 · 627 阅读 · 0 评论 -
749 A. Bachgold Problem
#includeusing namespace std;int num[500005];int main(){ int n; int sum=0; cin>>n; while(n) { if(n==1) { num[sum]++; break; }原创 2016-12-22 17:14:33 · 584 阅读 · 0 评论 -
746 D. Green and Black Tea codeforces
思路:先放多的,多的都是以k个连成一块,然后少的往里插。#includeusing namespace std;char str[100005];int main(){ int n,k,a,b,flag; cin>>n>>k>>a>>b; char aa,bb; aa='G';bb='B'; if(a>b) { swap(原创 2016-12-22 17:07:39 · 488 阅读 · 0 评论 -
746 C. Tram codeforces
三种情况:—,列车在人的后面。二,列车与人重合。三,列车宰人的前面。不同情况下比较列车与走路所耗费的时间。 #includeusing namespace std;int main(){ int s,x1,x2,t1,t2,p,d; cin>>s>>x1>>x2; cin>>t1>>t2; cin>>p>>d; if(t1>=t2) {原创 2016-12-22 17:04:43 · 512 阅读 · 0 评论 -
746 B. Decoding codeforces
#includeusing namespace std;int main(){ int n; char str[2005],str1[2005]; scanf("%d",&n); scanf("%s",str); int len=strlen(str); for(int i=len-1;i>=0;i--) { str[原创 2016-12-22 16:55:28 · 354 阅读 · 0 评论 -
746 A. Compote codeforces
#includeusing namespace std;int main(){ int a,b,c; cin>>a>>b>>c; int sum=0; for(int i=1;i<=a;i++) { if(i*2<=b&&i*4<=c) { sum=i+i*4+i*2; }原创 2016-12-22 16:53:05 · 806 阅读 · 0 评论 -
743C. Vladik and fractions codeforces
#includeusing namespace std;int main(){ int n; cin>>n; if(n==1) cout<<-1<<endl; else cout<<n<<' '<<n+1<<' '<<n*(n+1)<<endl; return 0;}原创 2016-12-15 21:19:11 · 395 阅读 · 0 评论 -
745 A. Hongcow Learns the Cyclic Shift codeforces
#includeusing namespace std;int main(){ char str[105]; scanf("%s",str); int len=strlen(str),len1=0; for(int i=len-1;i>=0;i--) { str[i+1]=str[i]; } int l,r,l1,r1,原创 2016-12-23 23:20:33 · 445 阅读 · 0 评论 -
745 B. Hongcow Solves A Puzzle codeforces
#includeusing namespace std;char map1[505][505];struct node{ int l;int r; int num;}arr[505];int main(){ int n,m,flag; char x; cin>>n>>m; for(int i=1;i<=n;i++) {原创 2016-12-23 23:21:41 · 367 阅读 · 0 评论 -
Codeforces 778A. Pupils Redistribution
题意:给你两个序列,每个序列的数的范围是从1到5,问最少要交换多少次,使序列1与序列2相同。这个题当时没写出来,不知道是怎么模拟的,之后看了人家的博客后才明白。。。#include#define manx 100005using namespace std;int main(){ int n,x,a[6]={0},b[6]={0}; scanf("%d",&n);原创 2017-02-28 21:25:10 · 347 阅读 · 0 评论 -
748 C. Santa Claus and Robot codeforces
#includeusing namespace std;int main(){ int n; string str; cin>>n>>str; int n1=0,n2=0,sum=0; for(int i=0;i<str.size();i++) { if(str[i]=='L') { if原创 2016-12-27 22:17:44 · 431 阅读 · 0 评论 -
748 B. Santa Claus and Keyboard Check
#includeusing namespace std;mapmap1;mapmap2;int main(){ string str1,str2; cin>>str1>>str2; int flag=0,sum=0; for(int i=0;i<str1.size();i++) { if(map1[str1[i]]==NULL&&m原创 2016-12-27 22:16:46 · 413 阅读 · 0 评论 -
748 A. Santa Claus and a Place in a Class codeforces
#includeusing namespace std;int main(){ int n,m,k,now=1,flag=0,i,j; cin>>n>>m>>k; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(i==1&&j==1)原创 2016-12-27 22:16:06 · 379 阅读 · 0 评论 -
742 B - Arpa’s obvious problem and Mehrdad’s terrible solution codeforces
#include using namespace std; int num[1000005]; int main() { int n,x,temp; long long ans=0; cin>>n>>x; while(n--) { cin>>temp; ans+=num[temp^x];原创 2016-12-27 22:14:37 · 595 阅读 · 0 评论 -
742 A - Arpa’s hard exam and Mehrdad’s naive cheat codeforces
#include using namespace std; int main() { int n,num[10]; cin>>n; num[1]=8;num[2]=4;num[3]=2;num[4]=6; if(n==0) { cout<<1<<endl; } else { n%原创 2016-12-27 22:13:33 · 391 阅读 · 0 评论 -
742 C. Arpa's loud Owf and Mehrdad's evil plan codeforces
思路:在这个集合中找到一共有多少的环,如果环中元素个数为奇数,则不变,为偶数,则除以2,最后求出所有环的最小公倍数。#includeusing namespace std;int pre[105],n,num;bool visit[105];void dfs(int x,int now){ if(visit[now]) { num=-1;原创 2016-12-27 22:07:26 · 445 阅读 · 0 评论 -
745 C. Hongcow Builds A Nation codeforces (并查集)
#includeusing namespace std;bool visit[1005];int pre[1005],num;struct node{ int flag; int num1; int num2;}arr[1005];int find(int x){ int y=x; while(y!=pre[y]) {原创 2016-12-23 23:22:47 · 346 阅读 · 0 评论 -
743B. Chloe and the sequence codeforces
#includetypedef long long LL;using namespace std;int main(){ LL n,k,sum,x,y,flag; cin>>n>>k; if(k%2) { cout<<1<<endl; } else { sum=0; while(k)原创 2016-12-15 21:17:36 · 281 阅读 · 0 评论 -
743A. Vladik and flights codeforces
#includeusing namespace std;char str[100005];int main(){ int n,a,b; cin>>n>>a>>b; for(int i=1;i<=n;i++) { cin>>str[i]; } if(str[a]!=str[b]) { cout<<1<<e原创 2016-12-15 21:16:37 · 418 阅读 · 0 评论 -
740C.Alyona and mex codeforces
题意:找的每个子数组中的未出现的最小非负整数,即mex,然后在这些mex中找到最小的那个,并且使那个mex尽可能大。求出一个符合这些条件的数组。思路:最小mex的值即所有区间里长度的最小值。求数组中每个元素的值即为他们的下标(0到n-1)对mex取余后的值,因为这样每mex个长度的数据,元素值都是从0到mex-1,这样在所有区间中所求的未出现的最小非负整数都是mex,题目上说找出符合题意的数组原创 2016-11-27 13:16:48 · 560 阅读 · 0 评论 -
codeforces 732A Buy a Shovel(水题)
#includeusing namespace std;int main(){ int k,r; cin>>k>>r; for(int i=1;;i++) { if((k*i)%10==0) { printf("%d\n",i); break; }原创 2016-10-18 12:59:38 · 438 阅读 · 0 评论 -
codeforces 732C Sanatorium(数学题)
#includeusing namespace std;unsigned long long min1,max1,mid1,num[3];void compare(unsigned long long a,unsigned long long b,unsigned long long c) //比较三个值的大小{ num[0]=a;num[1]=b; num[2]=c;原创 2016-10-18 12:56:02 · 656 阅读 · 0 评论 -
Codeforces 731C Socks(并查集)
题意:给你n条袜子,一共有k种颜色,要求每天穿的两只袜子颜色相同,求需要最少改多少只袜子的颜色才能满足条件。把同一天穿的两只袜子利用并查集放到一块,最后形成了一个一个集合,找出每个集合中哪个颜色的袜子最多,再把集合中其他颜色的袜子变成那个颜色,最后把每个集合所求的值加起来就是答案。 #includeusing namespace std;int type[200005],pre[原创 2016-10-17 17:31:29 · 560 阅读 · 0 评论 -
721D Maxim and Array codeforces(模拟)
题意:给你一组数据,可以修改k次,每次对其中一个数进行+x或-x,然后把所有数相乘使得最后的乘积最小。思路:一:使所有数的绝对值乘积最大;二:数据中存在奇数个负数。首先找到初始数据中一共有几个负数num ,然后对于每一次修改,先找到绝对值最小的那个数,然后判断数据中是否有奇数个负数。如果是奇数,那个数的原值如果为负,则-x,否则+x;如果是偶数,那个数的原值如果为负,则+x,否则-x,最后原创 2016-10-26 20:21:20 · 315 阅读 · 0 评论 -
codeforces Transformation: from A to B (水题)
题意:给你两个数A和B让你把A转换成B,只能用两种方法,每一次让A乘2或者让A乘10加1,问你需要操作几次能成功,并把每一次更新的A值输出。首先想到的方法就是搜索dfs,但是每回在第五个数据测试时都RE。之后又想了想,发现每一次更新的数要么是奇数,要么是偶数,当是奇数是就是乘10加1,是偶数时就是乘2,所以从B往前推,只有两种可能,要是能推到A,测成功,否则失败。这个题真心水,是我想复杂了原创 2016-10-15 22:46:41 · 1260 阅读 · 2 评论 -
codeforces 721C journey(动态规划+拓扑排序)
当时比赛的时候没写出来,然后看了网上大牛的博客才明白的,也通过这个题明白了前向星,拓扑排序,收获挺大的。大牛的博客:http://www.cnblogs.com/ziliuziliu/p/5931553.html附上自己的代码,有注释,按我自己理解写的.#include#define INF 0x3f3f3f3fusing namespace std;int n,m,t,head原创 2016-10-25 14:32:16 · 919 阅读 · 1 评论 -
Canada Cup 2016 A. Jumping Ball codeforces(水题)
#includeusing namespace std;struct node{ int l;int r;}arr[200005];int main(){ int n,num=0; string str; cin>>n; cin>>str; int sum=0; for(int i=0;i<str.size();i++)原创 2016-10-23 10:22:07 · 297 阅读 · 0 评论 -
codeforces 732B Cormen — The Best Friend Of a Man (水题)
#includeusing namespace std;int main(){ int n,k,a[505]; cin>>n>>k; for(int i=1;i<=n;i++) { scanf("%d",&a[i]); } int rest; int sum=0; for(int i=2;i<=n;i++)原创 2016-10-18 13:00:49 · 480 阅读 · 0 评论 -
733A Grasshopper And the String codeforces(水题)
#includeusing namespace std;int main(){ char str[105]; cin>>str; int len=strlen(str); for(int i=len-1;i>=0;i--) str[i+1]=str[i]; int step=0,max1=0,now; for(int i=1;i原创 2016-11-01 23:42:56 · 410 阅读 · 0 评论 -
740B Alyona and flowers codeforces
#includeusing namespace std;int num[105],num1[105],arr[105];int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { cin>>num[i]; } int sum,x,y; for(int i=1;i<=m原创 2016-11-27 12:41:56 · 498 阅读 · 0 评论 -
740A Alyona and copybooks codeforces
#includeusing namespace std;int main(){ long long n,a,b,c; cin>>n>>a>>b>>c; if(n%4==0) { cout<<0<<endl; } else { int rest=n%4; rest=4-rest;原创 2016-11-27 12:40:45 · 239 阅读 · 0 评论 -
codeforces B. Spotlights
#includeusing namespace std;int map1[1005][1005];vectorrow[1005];vectorcol[1005];int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) {原创 2016-11-20 22:19:26 · 360 阅读 · 0 评论 -
codeforces A.Interview with Oleg
#includeusing namespace std;string str;int main(){ int n; cin>>n; cin>>str; int visit[1005]; char str1[4]="ogo"; memset(visit,0,sizeof(visit)); if(str.size()<=2)原创 2016-11-20 22:18:26 · 301 阅读 · 0 评论 -
735 D. Taxes
思路:一个偶数能由两个素数组成,一个奇数能由三个素数组成,判断奇数的时候有一个特殊情况,一个奇数可以分成一个偶数一个奇数,然而2是素数,所以把奇数分成2和一个奇数,然后判断那个奇数是不是素数,是输出2,不是输出3。#includeusing namespace std;int num=0;int main(){ int n,flag; cin>>n; if(n=原创 2016-11-29 22:34:47 · 255 阅读 · 0 评论 -
735 A. Ostap and Grasshopper codeforces
#includeusing namespace std;int main(){ int n,k; cin>>n>>k; string str; cin>>str; int x,y; for(int i=0;i<str.size();i++) { if(str[i]=='T') {原创 2016-11-29 22:29:01 · 414 阅读 · 0 评论 -
733D Kostya the Sculptor codeforces (贪心)
思路:因为雕刻小球只能选择长方体最小的边,所以如果将两个长方体拼在一块,只有将他们由最长边和次长边组成的那一面拼在一起,才能增加雕刻小球的直径,不然如果拼在一起的面中含有最小边,那最小边在新的长方体中仍然存在,这样并没有增大能雕刻的小球的直径。所以,让每个长方体的边长从大到小排序,然后如果两个长方体想拼接,必须是他们最长边和次长边组成的面全等才能拼接,以此类推。#includeusing n原创 2016-11-01 23:46:57 · 351 阅读 · 0 评论 -
733B Parade codeforces(水题)
#includeusing namespace std;struct node{ int l; int r; int x; int num;}arr[100005];bool cmp(node x,node y){ if(x.x<y.x) return true; return false;}int main(){原创 2016-11-01 23:43:55 · 275 阅读 · 0 评论 -
733C. Epidemic in Monstropolis codeforces(模拟)
写的不怎么好,有好多漏洞,到最后是看测试数据一点一点改才过的,不过也算得到锻炼了。 #include#define MAX 0x3f3f3f3fusing namespace std;long long a[505],b[505];struct node{ int l; int r;}arr[505];struct road{ int v; ch原创 2016-11-03 00:11:03 · 345 阅读 · 0 评论