标签:ext 个数 lsp its test ref write std positive
Time Limit: 1000MS | Memory Limit: 10000K | |||
Total Submissions: 51502 | Accepted: 21541 | Special Judge |
Description
Input
Output
Sample Input
2 6 19 0
Sample Output
10 100100100100100100 111111111111111111
题意:输入一个数n,求只有0和1的数并且还是n的倍数的数是多少
思路:直接dfs搜,暴力搜
#include <iostream> using namespace std; typedef unsigned long long ULL; int n; bool flag = false; void DFS(int step, ULL t) { if(step > 19 || flag) return; if (t % n == 0) { cout << t << endl; flag = true; return; } DFS(step + 1, 10 * t); DFS(step + 1, 10 * t + 1); } int main() { while (cin >> n) { if (!n) return 0; flag = false; DFS(1, 1); } return 0; }
标签:ext 个数 lsp its test ref write std positive
原文地址:https://www.cnblogs.com/DreamInPal/p/11406485.html