POJ 1426 Find The Multiple
2015-02-27 22:34
267 查看
题意:输入一个200以内的正整数,输出任意一个只有1和0组成的100位以内的这个数的倍数
链接:http://poj.org/problem?id=1426
思路:枚举每一位,判断是否能被n整除即可
注意点:可证明这个数一定在long long范围内,不需要高精度
以下为AC代码:
链接:http://poj.org/problem?id=1426
思路:枚举每一位,判断是否能被n整除即可
注意点:可证明这个数一定在long long范围内,不需要高精度
以下为AC代码:
Run ID | User | Problem | Result | Memory | Time | Language | Code Length | Submit Time |
13917588 | luminous11 | 1426 | Accepted | 740K | 157MS | G++ | 1160B | 2015-02-27 22:36:31 |
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include <vector> #include <deque> #include <list> #include <cctype> #include <algorithm> #include <climits> #include <queue> #include <stack> #include <cmath> #include <map> #include <set> #include <iomanip> #include <cstdlib> #include <ctime> #define ll long long #define ull unsigned long long #define all(x) (x).begin(), (x).end() #define clr(a, v) memset( a , v , sizeof(a) ) #define pb push_back #define mp make_pair #define read(f) freopen(f, "r", stdin) #define write(f) freopen(f, "w", stdout) using namespace std; //const double pi = acos(-1); //const double eps = 1e-10; //const int dir[[4][2] = { 1,0, -1,0, 0,1, 0,-1 }; ll n; int k; bool flag; void dfs ( ll x, int len ) { if ( flag )return; if ( len > 18 )return; if ( x % n == 0 ){ cout << x << endl; flag = 1; return; } dfs ( x * 10, len + 1 ); dfs ( x * 10 + 1, len + 1 ); } int main() { ios::sync_with_stdio( false ); while ( cin >> n && n ){ flag = 0; dfs ( 1LL, 0LL ); } return 0; }
相关文章推荐
- POJ 1426, Find The Multiple
- poj 1426 Find The Multiple
- POJ1426-Find The Multiple
- POJ-1426 Find The Multiple
- POJ 1426 Find The Multiple(打表)
- POJ1426 Find The Multiple
- POJ1426 Find The Multiple 解题报告
- poj 1426 Find The Multiple
- POJ 1426 Find The Multiple (附模运算公式)
- Poj 1426 Find The Multiple
- POJ1426,Find The Multiple,bfs...注意类型 5兆内存过了...
- POJ 1426 Find The Multiple
- POJ1426-Find The Multiple
- POJ 1426 Find the Multiple
- POJ_1426_Find The Multiple
- POJ 1426 Find The Multiple
- poj -- 1426 Find The Multiple (搜索)
- POJ 1426 Find The Multiple
- POJ 1426 Find The Multiple
- poj 1426 Find The Multiple (广搜)