Greedy Takahashi——UPC

简介: 题目描述Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:·If Takahashi has one or more cookies, eat one of his cookies.·Otherwise, if Aoki has one or more cookies, eat one of Aoki’s cookies.·If they both have no cookies, do nothing.

题目描述

Takahashi has A cookies, and Aoki has B cookies. Takahashi will do the following action K times:

·If Takahashi has one or more cookies, eat one of his cookies.

·Otherwise, if Aoki has one or more cookies, eat one of Aoki’s cookies.

·If they both have no cookies, do nothing.

In the end, how many cookies will Takahashi and Aoki have, respectively?


Constraints

·0≤A≤1012

·0≤B≤1012

·0≤K≤1012

·All values in input are integers.


输入


Input is given from Standard Input in the following format:


A B K


输出


Print the numbers of Takahashi’s and Aoki’s cookies after K actions.


样例输入


【样例1】
2 3 3
【样例2】
500000000000 500000000000 1000000000000


样例输出


【样例1】
0 2
【样例2】
0 0


提示


样例1解释

Takahashi will do the following:

·He has two cookies, so he eats one of them.

·Now he has one cookie left, and he eats it.

·Now he has no cookies left, but Aoki has three, so Takahashi eats one of them.

Thus, in the end, Takahashi will have 0 cookies, and Aoki will have 2.

———————————————————————————————————————

很水,直接放代码


#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
start{
    ll a,b,k;
    cin>>a>>b>>k;
    if(k<=a) cout<<a-k<<" "<<b<<endl;
    else if(k<=a+b) cout<<0<<" "<<b+a-k<<endl;
    else cout<<0<<" "<<0<<endl;
    end;
}
/**************************************************************
    Language: C++
    Result: 正确
    Time:1 ms
    Memory:2024 kb
****************************************************************/


目录
相关文章
UVa11565 - Simple Equations
UVa11565 - Simple Equations
54 0
|
人工智能
UPC-Match Matching(完全背包dp+字符串)
UPC-Match Matching(完全背包dp+字符串)
82 0
|
人工智能 BI
[Atcoder ARC124] XOR Matching 2-小思维 | 暴力
题意: 给出n,两个数列a[1] -> a[n],b[1] -> b[n] 问有多少个x,可以使得在我们任意一种方式排列b[]之后,有a[i] ^ b[i] == x (1 <= i <= n) 思路: 首先我们可以确定所有的答案一定在a[1] ^ b[i] (1 <= i <= n)之内,所以我们只需要将这些个x的解空间单独放到数组c[]里,然后遍历x的解空间c[],将c[i] ^ a[i]的结果记录在d[]里面,然后判断b[],d[]是否完全相同即可,如果完全相同,就可以记录答案,注意最终答案要进行去重
120 0
[Atcoder ARC124] XOR Matching 2-小思维 | 暴力
|
Windows
Prediction and Restriction——UPC
题目描述 At an arcade, Takahashi is playing a game called RPS Battle, which is played as follows: ·The player plays N rounds of Rock Paper Scissors against the machine. (See Notes for the description of Rock Paper Scissors. A draw also counts as a round.)
127 0
HDU-1017,A Mathematical Curiosity
HDU-1017,A Mathematical Curiosity
|
机器学习/深度学习
HDOJ 1334 Perfect Cubes(暴力)
HDOJ 1334 Perfect Cubes(暴力)
107 0
HDOJ 2131 Probability
HDOJ 2131 Probability
99 0
HDOJ(HDU) 1673 Optimal Parking
HDOJ(HDU) 1673 Optimal Parking
129 0