A. Olesya and Rodion
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputOlesya 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
题解: n个t 组成的数一定是t的倍数
考虑特殊 t=10的情况 (水)
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<queue> 5 #include<stack> 6 #include<cmath> 7 #define ll __int64 8 #define pi acos(-1.0) 9 #define mod 1000000007 10 using namespace std; 11 int n,t; 12 int main() 13 { 14 scanf("%d %d",&n,&t); 15 if(t<10) 16 { 17 for(int i=1;i<=n;i++) 18 printf("%d",t); 19 cout<<endl; 20 } 21 if(t==10) 22 { 23 if(n==1) 24 cout<<"-1"<<endl; 25 else 26 { 27 for(int i=1;i<n;i++) 28 printf("1",t); 29 cout<<"0"<<endl; 30 } 31 } 32 return 0; 33 }
分类:
水
, codeforces
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· DeepSeek 解答了困扰我五年的技术问题。时代确实变了!
· 本地部署DeepSeek后,没有好看的交互界面怎么行!
· 趁着过年的时候手搓了一个低代码框架
· 推荐一个DeepSeek 大模型的免费 API 项目!兼容OpenAI接口!