• Coins


    Coins
    Input file: standard input
    Output file: standard output
    Time limit: 1 second
    Memory limit: 1024 megabytes
    In ICPCCamp, people usually use coins of value 1; 2; 3.
    Bobo was very poor, he had only a1; a2; a3 coins of value 1; 2; 3, respectively. He bought an item of an
    unknown value without making change.
    The unknown item was of positive integral value. Find out the number of possible values of it.
    Input
    3 integers a1; a2; a3 (0  a1; a2; a3  109).
    Output
    An integer denotes the number of possible values of the unknown item.
    Examples
    standard input standard output
    1 0 1 3
    0 0 0 0
    Note
    In the first sample, Bobo can only buy a item with value 1; 3 or 4 without making change.

    分析:需要很强的手推(yy)的技巧,否则就GG了。。。

    代码:

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <algorithm>
    #include <climits>
    #include <cstring>
    #include <string>
    #include <set>
    #include <map>
    #include <queue>
    #include <stack>
    #include <vector>
    #include <list>
    #define rep(i,m,n) for(i=m;i<=n;i++)
    #define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
    #define mod 1000000007
    #define inf 0x3f3f3f3f
    #define vi vector<int>
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define ll long long
    #define pi acos(-1.0)
    #define pii pair<int,int>
    #define Lson L, mid, rt<<1
    #define Rson mid+1, R, rt<<1|1
    const int maxn=2e5+10;
    using namespace std;
    ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
    ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
    int n,m,k,t;
    inline ll read()
    {
        ll x=0;int f=1;char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
        return x*f;
    }
    int a,b,c;
    ll ans;
    int main()
    {
        int i,j;
        scanf("%d%d%d",&a,&b,&c);
        if(a&&b&&c)
        {
            printf("%lld
    ",(ll)a+2*b+3*c);
        }
        else if(a&&b)
        {
            ans+=(ll)2*b+a;
            printf("%lld
    ",ans);
        }
        else if(b&&c)
        {
            if(b==1)printf("%lld
    ",(ll)2*c+1);
            else printf("%lld
    ",(ll)2*b+3*c-2);
        }
        else if(a&&c)
        {
            if(a==1)printf("%lld
    ",(ll)c*2+1);
            else printf("%lld
    ",(ll)3*c+a);
        }
        else printf("%lld
    ",(ll)a+b+c);
        //system("Pause");
        return 0;
    }
  • 相关阅读:
    【转】如何保护自己的QQ号
    13. 查看数据库对象间的依赖关系
    12. 查询数据库账号的所有权限
    11. 查询数据库各种历史记录
    如何找回SQL Server实例安装时的序列号
    SQL Server Mobile/Compact Edition 简单介绍
    6. SQL Server数据库监控
    5. SQL Server数据库性能监控
    4. SQL Server数据库状态监控
    3. SQL Server数据库状态监控
  • 原文地址:https://www.cnblogs.com/dyzll/p/5927458.html
Copyright © 2020-2023  润新知