Codeforces 584A Olesya and Rodion 【构造】
来源:互联网 发布:淘宝工业产品许可证号 编辑:程序博客网 时间:2024/06/03 14:32
题目链接:Codeforces 584A Olesya and Rodion
A. Olesya and Rodion
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Olesya loves numbers consisting of n digits, and Rodion only likes numbers that are divisible by t. Find some number that satisfies both of them.
Your task is: given the n and t print an integer strictly larger than zero consisting of n digits that is divisible by t. If such number doesn’t exist, print - 1.
Input
The single line contains two numbers, n and t (1 ≤ n ≤ 100, 2 ≤ t ≤ 10) — the length of the number and the number it should be divisible by.
Output
Print one such positive number without leading zeroes, — the answer to the problem, or - 1, if such number doesn’t exist. If there are multiple possible answers, you are allowed to print any of them.
Examples
input
3 2
output
712
题意:让你构造一个n位的正整数使得它可以被t整除,不存在输出-1。
思路:特判,先填好前面,然后后面全填0。
AC代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <iostream>#include <queue>#include <cmath>#define fi first#define se second#define ll o<<1#define rr o<<1|1#define CLR(a, b) memset(a, (b), sizeof(a))using namespace std;typedef long long LL;typedef pair<int, int> pii;const int MOD = 1e4 + 7;const int MAXN = 1e5 + 10;void add(LL &x, LL y) { x += y; x %= MOD; }int main(){ int n, t; while(scanf("%d%d", &n, &t) != EOF) { if(n == 1 && t == 10) { printf("-1\n"); continue; } if(t == 10) { t = 1; } printf("%d", t); for(int i = 1; i < n; i++) { printf("0"); } printf("\n"); } return 0;}
- Codeforces 584A Olesya and Rodion 【构造】
- Codeforces 584 A. Olesya and Rodion 数论+找规律(构造)
- Codeforces Round #324 (Div. 2) 584A. Olesya and Rodion
- Codeforces--584A--Olesya and Rodion(水题)
- CodeForces - 584A Olesya and Rodion (模拟)水
- codeforces——584A——Olesya and Rodion
- Codeforces Round #324 A Olesya and Rodion
- Codeforces Olesya and Rodion
- A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces Round #324 (Div. 2)A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces 584 A. Olesya and Rodion(Codeforces Round #324 (Div. 2))
- 【Codeforces Round 324 (Div 2)A】【水题】Olesya and Rodion 构造数长度为n且是t的倍数
- Code Forces 584 A. Olesya and Rodion(水~)
- cf#324-A. Olesya and Rodion-水题
- cf#324 Div.2 Problem A Olesya and Rodion
- Android Studio Error:Could not read entry ':app:packageDebug' from cache taskArtifacts.bin
- 第六周项目(1)-分数类雏形
- 编译windows版nginx-rtmp-module
- YouKu iOS笔试题二
- 最长回文子串
- Codeforces 584A Olesya and Rodion 【构造】
- 开源日志系统比较:scribe、chukwa、kafka、flume
- 【杭电】[2099]整除的尾数
- 伪主动触发input:file的click事件
- 冒泡排序
- android开发--volley的使用
- POJ2253 Frogger
- 手机内存、sdcard读写操作学习笔记
- Myclipse发布项目错误问题已解决