CodeForces 374A. Divisible by Seven
来源:互联网 发布:js回调函数获取返回值 编辑:程序博客网 时间:2024/04/29 11:53
构造。。。。
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;bool sh[10010000];int main(){string str;int cnt = 0, mod = 0;cin >> str;int n = str.size();memset(sh, true, sizeof(sh));bool n1 = false, n6 = false, n8 = false, n9 = false;for (int i = 0; i < n; i++){int b = str[i] - '0';if (b == 0){sh[i] = false;cnt++; continue;}if (b == 1 && !n1){n1 = true;sh[i] = false;continue;}if (b == 6 && !n6){n6 = true;sh[i] = false;continue;}if (b == 8 && !n8){n8 = true;sh[i] = false;continue;}if (b == 9 && !n9){n9 = true;sh[i] = false;continue;}mod = (mod * 10 + b) % 7;}mod = (mod * 10000) % 7;for (int i = 0; i < n; i++){if (sh[i]) putchar(str[i]);}if (mod == 0){printf("1869");}else if (7 - mod == 1){printf("1968");}else if (7 - mod == 2){printf("1689");}else if (7 - mod == 3){printf("6198");}else if (7 - mod == 4){printf("1698");}else if (7 - mod == 5){printf("1986");}else if (7 - mod == 6){printf("1896");}while (cnt--){putchar('0'); }///system("pause");return 0;}
1 0
- CodeForces 374A. Divisible by Seven
- CodeForces 375A Divisible By Seven
- CodeForces 375A Divisible by Seven
- CodeForces 375A Divisible by Seven
- Divisible by Seven CodeForces
- CF-375A Divisible by Seven
- Divisible by Seven
- C. Divisible by Seven
- Codeforces Round #221 (Div. 2)-C. Divisible by Seven
- A. Divisible by Seven----打表暴力/数学思维
- codeforces 376C Divisible by Seven(能被7整除的数)
- codeforce 221 Div2 C - Divisible by Seven
- Code forces 376 C Divisible by Seven
- Codeforces Round #221 (Div. 2) B. I.O.U. C. Divisible by Seven D. Maximum Submatrix 2 解题报告
- CF 376C Divisible By Seven 同余+暴力
- Codeforces 346A By Assassin
- how many positive integers are divisible by a number d in range [x,y]?
- 问题 B: Divisible by 3
- 淘宝应对双"11"的技术架构分析
- 标记入栈法,完全二叉树的前序遍历
- 转:创业者的迷惘女友们:如果爱,应该怎么爱?
- android开发问题:无法更新SDK manager升级包
- redhat as4之系统硬件查看
- CodeForces 374A. Divisible by Seven
- spring mvc json返回防止乱码
- ULONG64转CString
- opencv中mat,cvmat,Iplimage构造体定义以及格式互相转换
- Have a try on Ninja
- java 多线程 CountDownLatch用法
- 图灵1月书讯:阅新书辞旧岁,览经典迎新年
- 毒药与老鼠-程序实现
- hibernateTemplate和hibernateDaoSupport的注意问题!