Gym 100735 - I. Yet another A + B
来源:互联网 发布:java 字符串排序函数 编辑:程序博客网 时间:2024/06/08 00:10
题目链接:
http://codeforces.com/gym/100735/problem/I;
题意:
给出三个数A,B,C,如果三个数随机排列满足 两个相加等于第三个 的情况输出YES, 否则NO
题解:
大数加法
AC代码 (来自hacb教练)
#include <iostream>#include <algorithm>#include <string>#include <cstring>#include <stdio.h>using namespace std;struct Tr{ int num[120]; Tr operator+(Tr a)const { Tr tm; memset(tm.num, 0, sizeof(tm.num)); int in = 0, i; for (i = 0;i < 120;i++) { tm.num[i] = (num[i]+a.num[i]+in)%10; in = (num[i]+a.num[i]+in)/10; } return tm; } bool operator==(Tr a)const { int i; for (i = 119;i >= 0;i--) { if (num[i] != a.num[i]) return false; } return true; }}A, B, C;char a[110], b[110], c[110];int main() { int i, j; while (~scanf("%s%s%s", a, b, c)) { memset(A.num, 0, sizeof(A.num)); memset(B.num, 0, sizeof(B.num)); memset(C.num, 0, sizeof(C.num)); int la = strlen(a), lb = strlen(b), lc = strlen(c); for (i = la-1;i >= 0;i--) A.num[la-1-i] = a[i]-'0'; for (i = lb-1;i >= 0;i--) B.num[lb-1-i] = b[i]-'0'; for (i = lc-1;i >= 0;i--) C.num[lc-1-i] = c[i]-'0'; if (A+B == C || A+C == B || B+C==A) puts("YES"); else if (A+A == C || B+B==C || B+B==A || C+C == B || C+C == A || A+A==B) puts("YES"); else puts("NO"); }}
0 0
- Gym 100735 - I. Yet another A + B
- Gym 100735I Yet another A + B (java大数)
- Yet another A + B——KTU Programming Camp (Day 1) I题
- Yet Another Median Task Gym
- Yet Another Median Task Gym
- Java大数简单题---Yet another A + B
- Gym 100741G Yet Another Median Task
- GYM 100488 A. Yet Another Goat in the Garden(计算几何)
- Codeforces Gym 100741G Yet Another Median Task 二分乱搞
- GYM 100488 Yet Another Goat in the Garden
- 1001 - Another A+B
- Another A+B
- Another a+b FZU
- Yet another implementation of a lock-free circular array queue
- Yet another implementation of a lock-free circular array queue
- HUST 1001 Another A+B
- CodeForces Gym 100735I
- Yet Another Multiple Problem
- 安卓字体渲染器
- CodeBlocks主程序添加头文件失败解决方法
- mysql的备份
- 设置Android app的字体不随系统全局字体大小的变动而变动
- Codeforces697B Barnicle 模拟
- Gym 100735 - I. Yet another A + B
- 线程同步——互斥量
- mac快捷键
- 导出excel 02
- Android设置中“强行停止”详解
- log 4j配置文件log4j.properties
- 关于爱拍(拍视频)
- scipy module 1 -- Scipy Tutorial 5 Statistics
- java 保留小数点后两位的几种方法举例