`
暴风雪
  • 浏览: 374994 次
  • 性别: Icon_minigender_2
  • 来自: 杭州
社区版块
存档分类
最新评论

Codeforces Round #280 (Div. 2)

 
阅读更多
//A
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int num[300];
int main(){
    num[1] = 1;
    num[2] = 3;
    for(int i=3;i<200;i++){
        num[i] = num[i-1] + i;
//        cout<<i<<" "<<num[i]<<endl;
    }
    int n;
    scanf("%d",&n);
        int ans = 0,k=1;
        while(n-num[k]>=0){
            n-=num[k++];
            ans++;
        }
        cout<<ans<<endl;

    return 0;
}

 

//B
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll num[1010];
ll n,l;
int main(){
    while(scanf("%I64d%I64d",&n,&l)!=EOF){
        ll mds = 0;
        num[0] = 0;
        for(int i=1;i<=n;i++){
            scanf("%I64d",&num[i]);
        }
        sort(num+1,num+n+1);
        for(int i=2;i<=n;i++)
            mds = max(mds , num[i]- num[i-1]);
//        cout<<mds<<endl;
        double res = (mds*1.0)/2;
        res = max(res ,(l*1.0)-(num[n]*1.0));
        res = max(res,num[1]*1.0);
        printf("%.10lf\n",res);
    }
    return 0;
}

 

//C
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
//////////
#include<cmath>
using namespace std;
typedef long long ll;
struct axx{
    long long a,b;
}node[100100];
bool cmp(axx a,axx b){
    if(a.b<b.b)return 1;
    return 0;
}
ll r,avg;
int n;
int main(){
    while(cin>>n>>r>>avg){
        long long tot=0;
        for(int i = 1 ;i<=n; i++){
            scanf("%I64d%I64d",&node[i].a,&node[i].b);
            tot += node[i].a;
        }
        ll need = avg*n-tot;
        if(need<=0ll){
            cout<<0<<endl;
            continue;
        }
        sort(node+1,node+n+1,cmp);
        ll ans =0;
        for(int i = 1;i<=n;i++){
            ll can = (r-node[i].a);
            if(can>=need){
                ans+=need*node[i].b;
                break;
            }else{
                ans+=can*node[i].b;
                need -=can;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

 

//D
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long ll;
const ll nMax = 10010000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
int isvya[nMax];
void gao(ll x,ll y,ll ggd){
    long long tmp = 0,a = 0, b = 0,k = 1;
    while(tmp != ggd){
        if(x*(a+1)<y*(b+1)){
            a++;
            isvya[k++] = 1;
            tmp = x*a;
        }else{
            b++;
            isvya[k++] = 2;
            tmp = y * b;
        }
    }
}
int main(){
    ll n,x,y,a;
    while(cin>>n>>x>>y){
        ll gd = gcd(x,y);
        ll ggd = x/gd*y;
        gao(x,y,ggd);
//        cout<<ggd<<endl;
        ll ax = ggd/x + ggd/y;
//        cout<<ax<<endl;
        while(n--){
            scanf("%I64d",&a);
            a = a % ax;
            if(a%ax == 0 || a%(ax - 1) == 0){
                cout<<"Both\n";
                continue;
            }
            if(isvya[a] == 2){
                cout<<"Vanya"<<endl;
            }else{
                cout<<"Vova"<<endl;
            }
        }

    }
    return 0;
}
/*
7 5 20
26
27
28
29
30
31
32

*/

 

2
5
分享到:
评论

相关推荐

    Codeforces Round #723 (Div. 2).md

    Codeforces Round #723 (Div. 2).md

    Codeforces Round #630 (Div. 2) D. Walk on Matrix(构造)

    上面代码跑出来的dp[n][m]是0,然后从(1,1)(1,2)(2,2)(2,3)这样的相与值是k (看懂ans+k是啥应该就懂了) 代码: int main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int ans=(1&...

    Codeforces Round #627 (Div. 3) C. Frog Jumps(思维)

    传送门 题意: 开始位置在0,问能否跳到n+1位置 每步只能跳d 在1——n每个位置有方向,L,R,求d的最小值 思路: 只用找相邻两个R之间的最大值即可 代码: #include #include ...typedef long long l

    Codeforces Round #627 (Div. 3) B. Yet Another Palindrome Problem

    就是把所有相等的数放到一个vector里,如果他出现大于2次,看最远的间距是否大于2即可,找到一个就可以 代码: #include #include #include #include #include #include #include #include #include #include #...

    Codeforces Round #629 (Div. 3) B. K-th Beautiful String

    长度为n的字符串包含n−2n−2n−2个aaa和222个bbb,求按照字典序排列输出第kkk个字符串 解题思路 第一个bbb在倒数第二位有1个字符串,在倒数第三位有2个字符串…在倒数第nnn位时有n−1n-1n−1个字符串 可以根据第一...

    Codeforces Round #479 (Div. 3) E. Cyclic Components

    E. Cyclic Components 题目链接-E. Cyclic Components 题目大意 给你nnn个点和mmm条边,求所构成图中单圈环的个数 ...并查集并查集并查集 很明显单圈环每个点的度都为222,所以我们可以用数组cnt[]记录每个点的度,...

    Codeforces Round #629 (Div. 3) E.Tree Queries (DFS)

    Codeforces Round #629 (Div. 3) E.Tree Queries (DFS) 思路:若ai 在路径上 ,则ai的父结点一定在路径上,若ai是路径上某个结点的子结点,则ai的父结点一定在路径上,综上只需考虑ai的父节点就行了。对每个ai判断...

    Codeforces Round #628 (Div. 2)

    给两两节点放一个数字(0~n-2 唯一) 给你一棵树,求所有任意两节点相连的路以外的路上的数字的最小值最小 思路 构造 若一个点连了三条边及以上,则这个点的边从最小值开始赋值。其他边从最大点开始赋值。 证明:一...

    Codeforces Round #627 (Div. 3) A. Yet Another Tetris Problem

    给一个长度为n的数组,两种操作,一个是把任意一个ai变成ai+2a_i变成a_i+2ai​变成ai​+2,另一个是如果所有数都大于0,可以把所有数减1,问通过这些操作能否把所有数变为0 思路: 如果任意两个数之差为奇数,那么就...

    Codeforces Round #628 (Div. 2) A. EhAb AnD gCd

    输入一个正整数x,找出这样的2个正整数a和b,使得gcd(a,b)+lcm(a,b)=x 解题思路 找最特殊的情况a=1,b=x-1即可 这样a,b两个数最大公因数为1,最小公倍数x-1,满足题意√ 附上代码 #include #define int long long #...

    Codeforces Round #620 (Div. 2) Longest Palindrome

    B. Longest Palindrome time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Returning back to problem solving, Gildong is now studying about ...

    Codeforces Round #618 (Div. 2) C. Anu Has a Function(进制,位运算,贪心)

    将所有数字看成2进制,从最高位看起,如果第i位上为1的数只有一个的话,那么这个数必然对答案有贡献,就把它排在第一个,后面任意排。 例:11,6,4,0 二进制表示为:1011,110,100,0 右起第四位为1的只有1011,...

    Educational Codeforces Round 83 (Rated for Div. 2) D

    C(n-2,i-1)*C(j-1,n-2)*(i-1) __ j: n-1 -&gt; m 我们发现内层循环,每次只是j加一,我们就可以只用一次组合数剩下的用差量表示 对于外层循环同理 只有(i-1) * C(n-2,i-1) i会每次加一。我们也只算一次剩下的用差量...

    Codeforces Round #635 (Div. 2)D. Xenia and Colorful Gems

    传说门 刚好今晚是中国场! 其实这道题比较水,但当时思路错,一心想着化简公式,浪费了好多时间a....#pragma GCC optimize(2) #include #define ll long long #define endl '\n' using namespace std; const int manx=

    Codeforces Round #633 (Div. 2) A. Filling Diamonds(找规律)

    传送门 题意: 找规律,题意就是有多少种方式填充该图形 画两个就发现,输出n即可 代码: #include #include #include #include #include #include #include #include ...#define SZ(x) ((int)(x)

    Codeforces Round #628 (Div. 2) A~~D

    A #include using namespace std; typedef long long ll; int main(){ int t; cin&gt;&gt;t; while(t--){ ll x; cin&gt;&gt;x; cout&lt;&lt;1&gt;&gt;t; while(t--){ st.clear(); ll n; cin &gt;&gt;n;... ll re

    【Codeforces Round#620 (Div. 2)】B. Longest Palindrome 题解

    题目链接:B. Longest Palindrome 题目 Returning back to problem solving, Gildong is now studying about palindromes. He learned that a palindrome is a string that is the same as its reverse....

    Codeforces Round #629 (Div. 3) E – Tree Queries dfs序判祖先关系

    惭愧,前几天刚学的dfs序判祖先关系都忘了用。。 这题我们先把所有点都变成父亲节点(根节点不变),这样只需要判所有节点是否在一条链上。 由于判断x是y的祖先:需要满足:st[x]&lt;...const int M = 2e5+

Global site tag (gtag.js) - Google Analytics