- 博客(12)
- 收藏
- 关注
原创 codeforces.com/contest/1447/problem/A Add Candies
传送门codeforce1447A大致意思:n个数分别为1 、 2 、 3… n 1、2、3…n1、2、3…n,现在有一种操作,第j 次操作能让除开被操作数的其他所有数都加上j 。如果最后n 个数相等,输出需要几次操作,与每次被操作的数的下标。思路:要让所有的数相等,那么让相等时所有的数都等于1 到n 的和,对于第一个数 他已经有一个1 ,那么就对除开它本身的所有数加上1 ,对第二个数,它现在是2 + 1 ,其他的数少了一个2 ,那么就对除开它本身的所有数加上2 …以此类推,加到最后都是1 到n 的和
2020-11-28 16:39:11 173
原创 Registration system
A new e-mail service “Berlandesk” is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that’s why they ask you to help. You’re suggested to implement the prototype of site registrat
2020-11-28 16:06:05 201
原创 codeforces1A Theatre Square
传送门Theatre Square in the capital city of Berland has a rectangular shape with the size n × m meters. On the occasion of the city’s anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a × a.Wh
2020-11-28 13:32:12 148
原创 codeforces.ml/problemset/problem/4/A Watermelon
One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to d
2020-11-28 13:14:08 468
原创 随机数的生成
#include <stdio.h>#include <stdlib.h>#include <time.h>int main() { //添加随机数种子 srand((size_t)time(NULL)); //将系统时间作为随机种子,size_t为无符号整型 time_t tm = time(NULL); //获取系统时间 printf("系统时间为:%d\n", tm); for (int i = 0; i < 30000; i++)
2020-11-25 17:31:06 110
原创 codeforce158A-next round
“Contestant who earns a score equal to or greater than the k-th place finisher’s score will advance to the next round, as long as the contestant earns a positive score…” — an excerpt from contest rules.A total of n participants took part in the contest (n
2020-11-15 19:03:05 129
原创 codeforce-71A :way too long words
Sometimes some words like “localization” or “internationalization” are so long that writing them many times in one text is quite tiresome.Let’s consider a word too long, if its length is strictly more than 10 characters. All too long words should be repla
2020-11-15 18:56:23 622
原创 CodeForces - 141A-Amusing Joke
一道简单题,但get到了新知识点。(string和strcat,strstr)string用法#include<iostream>#include<string>#include<algorithm>using namespace std;int main(){ string s,s1,s2,s3; while(cin>>s>>s1>>s2){ s3=s+s1; sort(s2.begin(),s2.end())
2020-11-13 22:47:07 154
原创 2020/11/10/HDU 6182 && 2017广西邀请赛:A Math Problem
一道快速幂和暴力的简单题,但用了pow一直wa,即使用自己写的pow也一直wa,后来觉得大概是自己用的pow的名字与内部的pow相同了,后来将自己写的pow改成了qpow,终于过了。pow:精度问题。#include<iostream>#include<string.h>#include<stdio.h>#include<cmath>using namespace std;typedef long long ll;ll qpow(ll a,i.
2020-11-10 12:59:52 122
原创 代码练习2020/10/20-约瑟夫环
公式法:问题变为(N-1)个人,报到为(M-1)的人自杀,问题规模减小了。这样一直进行下去,最后剩下编号为0的人。用函数表示:F(1)=0当有2个人的时候(N=2),报道(M-1)的人自杀,最后自杀的人是谁?应该是在只有一个人时,报数时得到的最后自杀的序号加上M,因为报到M-1的人已经自杀,只剩下2个人,另一个自杀者就是最后自杀者,用函数表示:F(2)=F(1)+M可以得到递推公式:F(i)=F(i-1)+M因为可能会超出总人数范围,所以要求模F(i)=(F(i-1)+M)%i#inclu
2020-10-20 23:24:20 119
原创 抽签
你的朋友提议玩一个游戏,将写有数字的n张纸片放入口袋中,你可以从口袋中抽取4次卡片,每次记下卡片上的数字后都将其放入口袋中,如果这4个数字的和就是m,就是你赢,怎样抽取。1<=n<=50,1<=m<=10^8,1<=ki<=10^8样例:n=3m=10ki=1 3 5输出,yesn=3m=9ki=1 3 5输出 no#include<stdio.h>int max_N=50;int main(){ int n,m,k[max_N
2020-07-18 18:39:51 112
原创 My first C program--hello world
My first C program--hello world#include<stdio.h>int main(){printf(“hello world\n”);return 0;}
2019-11-30 11:14:25 282
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人