codeforces #324 div 2 A. Olesya and Rodion
2015-10-11 23:53
239 查看
A. Olesya and Rodion
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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.
Sample test(s)
input
output
构造题.
让构造任意一个n位数满足整除t
由于t是个位数==
所以很水.
-1的话只有n为1t为10的情况.
具体见代码...写得有点丑QAQ
View Code
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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.
Sample test(s)
input
3 2
output
712
构造题.
让构造任意一个n位数满足整除t
由于t是个位数==
所以很水.
-1的话只有n为1t为10的情况.
具体见代码...写得有点丑QAQ
/************************************************************************* > File Name: code/cf/#324/A.cpp > Author: 111qqz > Email: rkz2013@126.com > Created Time: 2015年10月11日 星期日 23时32分46秒 ************************************************************************/ #include<iostream> #include<iomanip> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> #include<map> #include<set> #include<queue> #include<vector> #include<stack> #include<cctype> #define yn hez111qqz #define j1 cute111qqz #define ms(a,x) memset(a,x,sizeof(a)) using namespace std; const int dx4[4]={1,0,0,-1}; const int dy4[4]={0,-1,1,0}; typedef long long LL; typedef double DB; const int inf = 0x3f3f3f3f; int n,t; int main() { #ifndef ONLINE_JUDGE // freopen("in.txt","r",stdin); #endif cin>>n>>t; if (n==1&&t==10) { puts("-1"); return 0; } if (n==1) { cout<<t<<endl; return 0; } if (t==10) { for ( int i = 1 ; i <=n-1 ; i++) cout<<1; cout<<0<<endl; return 0; } for ( int i = 1 ; i <= n ; i++) cout<<t; cout<<endl; #ifndef ONLINE_JUDGE fclose(stdin); #endif return 0; }
View Code
相关文章推荐
- 每天要更新了
- ElasticSearch的基本用法与集群搭建
- git学习笔记之一
- xcode-select: error: tool ‘xcodebuild(转)
- Linux下搭建Apache环境,执行Apache ab进行网站压力测试
- UITextField的leftView和rightView属性
- Part 97 Performance of a multithreaded program
- c# 程序后台运行
- 为何使用dynamic_cast转换类指针时,需要虚函数?
- ubuntu 14.04 glade 联编,(超简单的模型),哪些问题,怎么解决?
- 解决VS2010控制台程序运行结束不显示请按任意键继续
- 软件测试管理之基础小结
- Part 95 to 96 Deadlock in a multithreaded program
- 简单学C——第四天
- Spring @Transactional (一)
- RenderTexture实现实时阴影绘制
- 远程医疗监护系统
- ServiceConnection中的方法调用
- springMVC @ModelAttribute学习
- Part 94 Difference between Monitor and lock in C#