Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
来源:互联网 发布:i5处理器编程够用么 编辑:程序博客网 时间:2024/06/06 03:17
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.
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.
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.
3 2
712
题意:要求构造一个n位数字,使得能被t整除
错因分析:做题的思维僵化,太过“暴力”
AC代码:
Wa代码#include <iostream>
#include<cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
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;
}
#include <iostream>
#include<cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include<map>
#include <algorithm>
#include <set>
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;
}
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) 584A. Olesya and Rodion
- Codeforces Round #324 (Div. 2)A. Olesya and Rodion
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion
- Codeforces Round #324 A Olesya and Rodion
- 【Codeforces Round 324 (Div 2)A】【水题】Olesya and Rodion 构造数长度为n且是t的倍数
- Codeforces 584 A. Olesya and Rodion(Codeforces Round #324 (Div. 2))
- Codeforces 584A Olesya and Rodion 【构造】
- cf#324 Div.2 Problem A Olesya and Rodion
- Codeforces Olesya and Rodion
- A. Olesya and Rodion
- cf#324-A. Olesya and Rodion-水题
- Codeforces 584 A. Olesya and Rodion 数论+找规律(构造)
- Codeforces--584A--Olesya and Rodion(水题)
- CodeForces - 584A Olesya and Rodion (模拟)水
- codeforces——584A——Olesya and Rodion
- Codeforces Round #410 (Div. 2)-A. Mike and palindrome-思维
- poj 3104 Drying 二分搜索--查找最小yes值
- poj 3111 K Best 二分搜索 最大化平均值
- POj 3258 River Hopscotch 二分搜索 最大化最小值
- poj 2674 Linear world 弹性碰撞 升级的蚂蚁
- poj 2785 4 Values whose Sum is 0
- Codeforces Round #324 (Div. 2) A. Olesya and Rodion 构造数字 思维题
- Codeforces Round #324 (Div. 2) B. Kolya and Tanya 思维题 数论
- Poj 3977 Subset 折半枚举 超大背包
- poj 2549 Sumsets 折半枚举
- poj 3276 Face The Right Way 挑战150 反转
- poj 3279 Fliptile 反转
- poj 3185 The Water Bowls 反转(开关)
- poj 1930 Dead Fraction 循环小数的处理
- poj 3421 X-factor Chains 素数筛选 因子分解