codeforces Round#158 Div.2 A
来源:互联网 发布:云南大学网络平台 编辑:程序博客网 时间:2024/06/16 12:24
题意:
给出一个数字 , 往其末尾加上n个数字,每次添加的时候保证其 % k == 0
输出最终数字
题解:
只需要保证第一个数字合法, 然后往后面加上n-1个0
代码 :
#include<stdio.h>#include<string.h>int main(){ int a, b, n; char s1[200010]; while(scanf("%d %d %d", &a, &b, &n) != EOF) { memset(s1, '\0', sizeof(s1)); sprintf(s1, "%d", a); int len = strlen(s1); int c = a % b, flag = 0, d; c *= 10; c %= b; d = (b - c) % b; if(d >= 10) {flag = 1;} else { s1[len ++] = (d + '0'); for(int i = 2; i <= n; i++) { s1[len ++] = '0'; } } if(flag) printf("-1\n"); else printf("%s\n", s1); }}
0 0
- codeforces Round#158 Div.2 A
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- Codeforces Round #132 (Div. 2) A题
- Codeforces Round #131 (Div. 2) A题
- Codeforces Round #133 (Div. 2) A题
- Codeforces Round #137 (Div. 2) A题
- Codeforces Round #138 (Div. 2) A题
- Codeforces Round #147 (Div. 2) A题
- Codeforces Round #141 (Div. 2) A题
- Codeforces Round #143 (Div. 2) A题
- Codeforces Round #135 (Div. 2) A题
- 九度1022 -栈 - 游船出租
- C++ (重载、覆盖、隐藏)区别
- 使用DDMS抓取安卓APP的奔溃日志
- webview的使用
- js倒计时实现
- codeforces Round#158 Div.2 A
- iOS本地推送
- 第十六周阅读程序(2)
- TOMCAT启动时报错:the CATALINA_HOME environment variable is not defined correctly
- Lucene:基于Java的全文检索引擎简介
- Centos 6.2 安装Mysql笔记
- SlidingMenu使用(二) Demo
- 提高篇第28-31课第三题
- org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 40