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");
}
目录
相关文章
HDU-1061,Rightmost Digit(快速幂)
HDU-1061,Rightmost Digit(快速幂)
|
安全
D-POJ-3126 Prime Path
Description The ministers of the cabinet were quite upset by the message from the Chief of...
1126 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互素。
906 0
|
机器学习/深度学习 并行计算 Java
hdu 4135 Co-prime【容斥原理】
Co-prime Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1668    Accepted Submission(s)...
1222 0
|
机器学习/深度学习