Codeforces--584A--Olesya and Rodion(水题)
2016-04-06 22:27
281 查看
Olesya and Rodion
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
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 Input
Input
Output
712
题意:输出一个长度为n的数,这个数可以被t整除,,很水的题,如果n是2--9的一个数,直接把这个数输出n次,如果n为1并且t=10,那么直接输出-1,如果t=0,n>1的话输出一个1,后边加上n-1个0
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n,t;
while(scanf("%d%d",&n,&t)!=EOF)
{
if(t>=2&&t<10)
{
for(int i=0;i<n;i++)
printf("%d",t);
printf("\n");
}
else
{
if(n==1&&t==10)
printf("-1\n");
else
{
printf("1");
for(int i=0;i<n-1;i++)
printf("0");
printf("\n");
}
}
}
return 0;
}
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Submit Status
Description
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 Input
Input
3 2
Output
712
题意:输出一个长度为n的数,这个数可以被t整除,,很水的题,如果n是2--9的一个数,直接把这个数输出n次,如果n为1并且t=10,那么直接输出-1,如果t=0,n>1的话输出一个1,后边加上n-1个0
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n,t;
while(scanf("%d%d",&n,&t)!=EOF)
{
if(t>=2&&t<10)
{
for(int i=0;i<n;i++)
printf("%d",t);
printf("\n");
}
else
{
if(n==1&&t==10)
printf("-1\n");
else
{
printf("1");
for(int i=0;i<n-1;i++)
printf("0");
printf("\n");
}
}
}
return 0;
}
相关文章推荐
- workSpace下多工程联编
- ATM机模拟消费
- 使用Navicat for Oracle新建表空间、用户及权限赋予---来自烂泥
- 电流环差分信号传送数字信号
- android下的读写权限
- Groovy1-基本类型与运算符
- openStack 主机流量计运行状态 随笔记录
- [IO]——文件的读取
- IPP 应用范围
- 模型开发与数据库交互--数据库处理
- 插入冒泡选择以及折半法排序
- 图论算法
- pip使用阿里云源进行加速
- 使用apache的poi包导出excel表格
- struts2表单提交时总是返回input
- linux内核参数优化
- 算法合集之《后缀数组——处理字符串的有力工具》
- 关于 javascript 处理json格式日期转换的方法
- 数字的反转
- 算法合集之《后缀数组——处理字符串的有力工具》