Codeforces Round #421 A

A. Mister B and Book Reading

题意:给你一本c页的数,第一天读v0页,以后每天读 的页数比前一天多a页(v0+a,v0+2a,v0+3a), 但是每天读的页数不超过v1页,且从第二天起,每天要从前一天的后 l 页读起(也就是每天都要将前一天的后l页再读一遍),求多少天可以读完这本数

思路:xjb模拟

AC代码:

#include "iostream"
#include "string.h"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "set"
#include "map"
#include "algorithm"
#include "stdio.h"
#include "math.h"
#define ll long long
#define bug(x) cout<<x<<" "<<"UUUUU"<<endl;
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
const int N=1e5+100;
int main(){
    int c,v0,v1,a,l;
    cin>>c>>v0>>v1>>a>>l;
    int ans=0,s=0,k=v0;
    while(c>s){
        if(ans!=0) s-=l;
        ans++;
        s+=k;
        k+=a;
        if(k>v1)k=v1;
    }
    cout<<ans<<endl;
    return 0;
}

/*
5 5 10 5 4
12 4 12 4 1
15 1 100 0 0
*/
时间: 2024-08-08 22:06:52

Codeforces Round #421 A的相关文章

Codeforces Round #421 (Div. 2)

A: 题意:给你一本书共c页,第一天看v0页,第二天看v0+a,第二天看v0+2a以此类推,每天最多看v1页,但是后一天要重复看前一天的后l页. 代码: #include<stdio.h>using namespace std;int c,v0,v1,a,l;int main(){ while(~scanf("%d%d%d%d%d",&c,&v0,&v1,&a,&l)) { int sum=v0; int k=1; while(sum

Codeforces Round #421 B

B. Mister B and Angle in Polygon 题意:给你一个正n边形(每个点顺时针依次为1 2 3...n),一个角度a,从多边形中任选3个点A B C 求最接近a的角ABC 输出ABC 思路:将n多边形外接一个圆,可知,当2个点确定的时候,角度就已经确定了(只考虑小于180度的情况),所以,确定一个点之后暴力另一个点就可以求得所有情况了(注意只要暴力到n-2就可以了) AC代码: #include "iostream" #include "string.

Codeforces Round #421 (Div. 2)B Mister B and Angle in Polygon

题目: 这里 题意:给一个正n(n <= 100000)边形和一个角度a,在正n边形n找到3个不同的顶点v1,v2,v3,使得 和a之间的差最小,并且输出v1,v2,v3: 思路:可以把这个多边形放在一个圆里面.发现的大小等于v1,v3对应圆心角/2.所有的角都是180/a的倍数.固定一个点的位置1,然后以2为圆心角的起点为n-1的终点枚举另一个点的位置即可. 代码: // #include<bits/stdc++.h> using namespace std; const int ma

codeforces round 421 div2 补题 CF 820 A-E

A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef long long int LL; const LL N=1,M=1,MOD=1; int main() {//freopen("t.txt","r",stdin); int c,v0,v1,a,l; scanf("%d%d%d%d%d",&c,&

Codeforces Round #421 (Div. 1) (BCDE)

1. 819B Mister B and PR Shifts 大意: 给定排列$p$, 定义排列$p$的特征值为$\sum |p_i-i|$, 可以循环右移任意位, 求最小特征值和对应移动次数. 右移过程中维护增加的个数和减少的个数即可. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <cmath> #include &

Codeforces Round #279 (Div. 2) ABCD

Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name     A Team Olympiad standard input/output 1 s, 256 MB  x2377 B Queue standard input/output 2 s, 256 MB  x1250 C Hacking Cypher standard input/output 1 s, 256 MB  x740 D Chocolate standard input/

Educational Codeforces Round 21 G. Anthem of Berland(dp+kmp)

题目链接:Educational Codeforces Round 21 G. Anthem of Berland 题意: 给你两个字符串,第一个字符串包含问号,问号可以变成任意字符串. 问你第一个字符串最多包含多少个第二个字符串. 题解: 考虑dp[i][j],表示当前考虑到第一个串的第i位,已经匹配到第二个字符串的第j位. 这样的话复杂度为26*n*m*O(fail). fail可以用kmp进行预处理,将26个字母全部处理出来,这样复杂度就变成了26*n*m. 状态转移看代码(就是一个kmp

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i

Codeforces Round #424 (Div. 2) D. Office Keys(dp)

题目链接:Codeforces Round #424 (Div. 2) D. Office Keys 题意: 在一条轴上有n个人,和m个钥匙,门在s位置. 现在每个人走单位距离需要单位时间. 每个钥匙只能被一个人拿. 求全部的人拿到钥匙并且走到门的最短时间. 题解: 显然没有交叉的情况,因为如果交叉的话可能不是最优解. 然后考虑dp[i][j]表示第i个人拿了第j把钥匙,然后 dp[i][j]=max(val(i,j),min(dp[i-1][i-1~j]))   val(i,j)表示第i个人拿