博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
阅读量:4112 次
发布时间:2019-05-25

本文共 2096 字,大约阅读时间需要 6 分钟。

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?≤?1002?≤?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整除
错因分析:做题的思维僵化,太过“暴力”
AC代码:
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std; #define MM(a) memset(a,0,sizeof(a)) typedef long long ll; typedef unsigned long long ULL; const int mod = 1000000007; const double eps = 1e-10; const int inf = 0x3f3f3f3f; int main() { int n, t; while (~scanf("%d %d", &n, &t)) { if (t != 10) for (int i = 1; i <= n; i++) cout << t; else if (n == 1) cout << "-1" ; else { cout << "1"; for (int i = 1; i <= n - 1; i++) cout << "0"; } cout << endl; } return 0; } Wa代码
#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std; #define MM(a) memset(a,0,sizeof(a)) typedef long long ll; typedef unsigned long long ULL; const int mod = 1000000007; const double eps = 1e-10; const int inf = 0x3f3f3f3f; int main() { int n,t; while (~scanf("%d %d",&n,&t)) { double l = 1en;//10^n,,会编译错误 while (l%t != 0) l++; printf("%.0f\n", l); } return 0; }

转载地址:http://cvgsi.baihongyu.com/

你可能感兴趣的文章
python实现100以内自然数之和,偶数之和
查看>>
python数字逆序输出及多个print输出在同一行
查看>>
ESP8266 WIFI数传 Pixhaw折腾笔记
查看>>
苏宁产品经理面经
查看>>
百度产品经理群面
查看>>
去哪儿一面+平安科技二面+hr面+贝贝一面+二面产品面经
查看>>
element ui 弹窗在IE11中关闭时闪现问题修复
查看>>
vue 遍历对象并动态绑定在下拉列表中
查看>>
Vue动态生成el-checkbox点击无法选中的解决方法
查看>>
python __future__
查看>>
MySQL Tricks1
查看>>
python 变量作用域问题(经典坑)
查看>>
pytorch
查看>>
pytorch(二)
查看>>
pytorch(三)
查看>>
pytorch(四)
查看>>
pytorch(5)
查看>>
pytorch(6)
查看>>
ubuntu相关
查看>>
C++ 调用json
查看>>