Skip to main content
  1. Tags/

Codeforces

2019

codeforces round 530 div2

·651 words·2 mins
A,B,C:都很简单,不说了。 D:一棵树,给出树的结构,以及从树根到某个深度为偶数的节点的路径和,问能否构造一种所有节点点权和最小的树,输出最小点权和。

codeforces hello 2019

·2045 words·5 mins
好久没玩cf了,竟然还能涨分(虽然我用的小号Orz) 三题,D应该是数学+DP…数学实在是忘干净了。。。

2018

2017

Codeforces eductional round 29

·2705 words·6 mins
比赛链接 10个月没写题了,菜啊。进行一点恢复性训练好了。 A: 给一个数,可以在填写若干(或者0)个前缀0,问能否变成回文数。

2016

codeforces #381 div2

·2406 words·5 mins
http://codeforces.com/contest/740 A:现在有n个某种物品,要买k个使得n+k是4的倍数,可以的购买方案为a元1个,b元2个,c元3个,每种方案都可以买无限多。

codeforces #346 div 2 A. Round House

·160 words·1 min
题目链接 水题 乱搞。 1/* *********************************************** 2Author :111qqz 3Created Time :2016年03月30日 星期三 23时59分47秒 4File Name :code/cf/#346/A.cpp 5************************************************ */ 6 7#include <cstdio> 8#include <cstring> 9#include <iostream> 10#include <algorithm> 11#include <vector> 12#include <queue> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <ctime> 19#define fst first 20#define sec second 21#define lson l,m,rt<<1 22#define rson m+1,r,rt<<1|1 23#define ms(a,x) memset(a,x,sizeof(a)) 24typedef long long LL; 25#define pi pair < int ,int > 26#define MP make_pair 27 28using namespace std; 29const double eps = 1E-8; 30const int dx4[4]={1,0,0,-1}; 31const int dy4[4]={0,-1,1,0}; 32const int inf = 0x3f3f3f3f; 33int n,a,b; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("code/in.txt","r",stdin); 38 #endif 39 cin>>n>>a>>b; 40 a = a + b; 41 while (a<=0) a+=n; 42 while (a>n) a-=n; 43 cout<<a<<endl; 44 45 #ifndef ONLINE_JUDGE 46 fclose(stdin); 47 #endif 48 return 0; 49}

codeforces #120 div 2 (Virtual Participation)

·938 words·2 mins
比赛链接 两题QAQ A:7分钟1A 有n个大人m个小孩乘公交车,票价每人一元,一个大人最多免费带一个小孩,没有大人陪同的小孩不能乘车。 问是否有解,如果有解输出所有乘客付的钱的可能的最小值和可能的最大值。

codeforces croc 2016 C. Enduring Exodus

·475 words·1 min
题目链接 题意:给出n和k,给出一个长度为n的字符串表示房间的占用情况(0表示没占用,1表示已占用),从n个房间中找出k+1个,使得k+1中的k个距离k+1个中的1个的距离和最小。

2015

codeforces 519 C. A and B and Team Training

·271 words·1 min
http://codeforces.com/problemset/problem/519/C 题意:两种组队方式,3人一组,1个大牛+2个蒟蒻或者1个蒟蒻+2个大牛。给定大牛和蒟蒻的个数。问最多能组多少队。 思路:线性规划。设两种队分别有x,y个即可。 突然发现这题以前做过。。。比当时的代码简单了一些。还不错。

codeforces #334 div 2 C. Alternative Thinking

·517 words·2 mins
题意:给定一个01串。要进行一次变换:选一段连续的非空的字串,将这段串的0和1反转(0变成1,1变成0) 然后问能得到的最长的0,1交替的序列的长度是多少(不一定连续)

codeforces #332 div 2 C. Day at the Beach

·561 words·2 mins
C. Day at the Beach time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Squidward, Spongebob and Patrick decided to go to the beach. Unfortunately, the weather was bad, so the friends were unable to ride waves. However, they decided to spent their time building sand castles.

codeforces #332 div 2 B. Spongebob and Joke

·651 words·2 mins
B. Spongebob and Joke time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output While Patrick was gone shopping, Spongebob decided to play a little trick on his friend. The naughty Sponge browsed through Patrick’s personal stuff and found a sequence _a_1, _a_2, …, a__m of length m, consisting of integers from 1 to n, not necessarily distinct. Then he picked some sequence _f_1, _f_2, …, f__n of length n and for each number a__i got number b__i = f__a__i. To finish the prank he erased the initial sequence a__i.

codeforces #332 div 2 A. Patrick and Shopping

·646 words·2 mins
1#include <cstdio> 2#include <iostream> 3#include <cmath> 4using namespace std; 5long long d1,d2,d3; 6int main() 7{ 8cin>>d1>>d2>>d3; 9long long ans = 999999999999; 10ans = min(ans,d1+d2+d3); 11ans = min (ans,d1*2+d2*2); 12ans = min (ans,d1*2+2*d3); 13ans = min(ans,d2*2+2*d3); 14cout<<ans<<endl; 15return 0; 16} time limit per test 1 second

codeforces 589 B - Layer Cake

·698 words·2 mins
B - Layer Cake **Time Limit:**6000MS **Memory Limit:**524288KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 589B Description Dasha decided to bake a big and tasty layer cake. In order to do that she went shopping and bought n rectangular cake layers. The length and the width of the i-th cake layer were a__i and b__i respectively, while the height of each cake layer was equal to one.

codeforces #324 div 2 A. Olesya and Rodion

·377 words·1 min
A. Olesya and Rodion time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them.

[转自codeforces] How to come up with the solutions: techniques

·901 words·2 mins
As I work with students I often face the situation when if a problem doesn’t seem clear to a student at the first sight, it makes them unable to solve it. Indeed, you always hear about specific methods and techniques. But you don’t hear about how to think in order to apply them. In this note I’ll try to sum up my experience of solving programming contest problems. However, some pieces of advice will also be applicable for olympiads in mathematics and your first steps in academic research.