zoukankan      html  css  js  c++  java
  • codeforce round 325 C/D/E

    C

    #include<bits/stdc++.h>
    using namespace std;
    const int MAX_N=4010;
    
    int n;
    long long d[MAX_N],p[MAX_N],v[MAX_N];
    int cure[MAX_N];
    
    int main()
    {
        freopen("C.in","r",stdin);
        while(~scanf("%d",&n)){
            int ans=0;
            for(int i=0;i<n;i++){
                scanf("%I64d%I64d%I64d",&v[i],&d[i],&p[i]);
            }
            for(int i=0;i<n;i++){
                if(p[i]<0) continue;
                cure[ans++]=i+1;
                long long cur=v[i],extra=0;
                for(int j=i+1;j<n;j++){
                    if(p[j]<0) continue;
                    p[j]-=(cur+extra);
                    if(p[j]<0) extra += d[j];
                    if(cur>0) cur--;
                }
            }
            printf("%d
    ",ans);
            for(int i=0;i<ans;i++){
                printf("%d ",cure[i]);
            }
            printf("
    ");
        }
        return 0;
    }
    View Code

    D

    #include<bits/stdc++.h>
    using namespace std;
    const int N = 1e5 + 10, INF = 0x3f3f3f3f, MOD = 1e9 + 7;
    
    int n, k, sx;
    char a[5][105];
    typedef pair<int, int> P;
    
    bool bfs(int sx) {
        queue<P> q; q.push(P(sx, 1));
        while(q.size()) {
            int x = q.front().first, y = q.front().second; q.pop();
            if(isalpha(a[x][++y])) continue;
            if(y >= n) return true;
            for(int i = -1; i <= 1; ++i) {
                int nx = x + i;
                if(nx < 1 || nx > 3) continue;
                if(isalpha(a[nx][y]) || isalpha(a[nx][y + 1])
                        || isalpha(a[nx][y + 2]) || a[nx][y + 2] == 1) continue;
                int ny = y + 2;
    //            pr(nx); prln(ny);
                if(ny >= n) return true;
                a[nx][ny] = 1;
                q.push(P(nx, ny));
            }
        }
        return false;
    }
    
    int main() {
    #ifdef LOCAL
        freopen("C:\Users\TaoSama\Desktop\in.txt", "r", stdin);
    //  freopen("C:\Users\TaoSama\Desktop\out.txt","w",stdout);
    #endif
        ios_base::sync_with_stdio(0);
    
        int t; scanf("%d", &t);
        while(t--) {
            scanf("%d%d", &n, &k);
            memset(a, 0, sizeof a);
            for(int i = 1; i <= 3; ++i) {
                scanf("%s", a[i] + 1);
                if(a[i][1] == 's') sx = i;
            }
            puts(bfs(sx) ? "YES" : "NO");
        }
        return 0;
    }
    View Code

    E

    #include<bits/stdc++.h>
    
    typedef long long ll;
    typedef unsigned long long ull;
    #define INF (1ll<<60)-1
    
    using namespace std;
    ll x,y;
    ll gcd(ll a,ll b){
        return b==0?a:gcd(b,a%b);
    }
    int main(){
        scanf("%I64d%I64d",&x,&y);
        if(gcd(x,y)!=1LL) printf("Impossible
    ");
        else {
            while(x && y){
                if(x>y){
                    if(y==1) x--;
                    printf("%I64dA",x/y);
                    x=x%y;
                } else {
                    if(x==1) y--;
                    printf("%I64dB",y/x);
                    y=y%x;
                }
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    Atitit. 真正的全中国文字attilax易语言的特点以及范例
    Atitit.nosql api 标准化 以及nosql数据库的实现模型分类差异
    Google&quot;员工&quot;曝内幕:Google员工的17个秘密
    WINDOWS 乱码解决
    计算机软件开发文档编写指南
    概要设计阶段概要设计说明书
    关于管理的经典故事(员工激励)
    概要设计阶段组装测试计划
    一个还不太老的程序员的体会
    程序员四大忌 你该如何避免呢?
  • 原文地址:https://www.cnblogs.com/zsben991126/p/12877369.html
Copyright © 2011-2022 走看看