UVa11679 - Sub-prime

简介: UVa11679 - Sub-prime
#include <cstdio>#include <cstring>usingnamespacestd;
constintN=21;
intb, n;
intcost[N];
boolinput();
voidsolve();
intmain()
{
#ifndef ONLINE_JUDGEfreopen("d:\\OJ\\uva_in.txt", "r", stdin);
#endifwhile (input()) {
solve();
    }
return0;
}
boolinput()
{
scanf("%d%d", &b, &n);
if (b==0&&n==0) returnfalse;
memset(cost, 0x00, sizeof(cost));
for (inti=1; i<=b; i++) {
scanf("%d", &cost[i]);
    }
for (inti=0; i<n; i++) {
intdebtor, creditor, debenture;
scanf("%d%d%d", &debtor, &creditor, &debenture);
cost[debtor] -=debenture;
cost[creditor] +=debenture;
    }
returntrue;
}
voidsolve()
{
boolok=true;
for (inti=1; i<=b; i++) {
if (cost[i] <0) {
ok=false;
break;
        }
    }
printf("%s\n", ok?"S" : "N");
}
目录
相关文章
|
4月前
|
Java
HDU-2199-Can you solve this equation
HDU-2199-Can you solve this equation
26 0
|
4月前
|
Java
HDU-2199-Can you solve this equation?
HDU-2199-Can you solve this equation?
30 0
|
机器学习/深度学习 网络架构
题解 UVA10212 【The Last Non-zero Digit.】
题目链接 这题在学长讲完之后和看完题解之后才明白函数怎么构造。这题构造一个$f(n)$$f(n)$ $=$ $n$除以 $2^{a}$ $*$ $5^{b}$ ,$a$ , $b$ 分别是 $n$ 质因数分解后$2,5$的个数。
1225 0
|
机器学习/深度学习
|
安全
D-POJ-3126 Prime Path
Description The ministers of the cabinet were quite upset by the message from the Chief of...
1122 0
容斥 - HDU 4135 Co-prime
Co-prime  Problem's Link:  http://acm.hdu.edu.cn/showproblem.php?pid=4135 推荐: 容斥原理 Mean:  给你一个区间[l,r]和一个数n,求[l,r]中有多少个数与n互素。
901 0