zoukankan      html  css  js  c++  java
  • 暴力枚举 UVA 725 Division

    题目传送门

     1 /*
     2     暴力:对于每一个数都判断,是否数字全都使用过一遍
     3 */
     4 #include <cstdio>
     5 #include <iostream>
     6 #include <algorithm>
     7 #include <cmath>
     8 #include <cstring>
     9 #include <string>
    10 #include <map>
    11 #include <set>
    12 #include <queue>
    13 using namespace std;
    14 
    15 const int MAXN  = 1e4 + 10;
    16 const int INF = 0x3f3f3f3f;
    17 int vis[10];
    18 
    19 bool ok(int x, int y)
    20 {
    21     memset (vis, 0, sizeof (vis));
    22     for (int i=1; i<=5; ++i)
    23     {
    24         vis[x%10]++;    vis[y%10]++;
    25         if (vis[x%10] > 1 || vis[y%10] > 1)    return false;
    26         x /= 10;    y /= 10;
    27     }
    28 
    29     return true;
    30 }
    31 
    32 int main(void)        //UVA 725 Division
    33 {
    34     //freopen ("UVA_725.in", "r", stdin);
    35 
    36     int n, cnt = 0;
    37     while (scanf ("%d", &n) == 1)
    38     {
    39         if (n == 0)    break;
    40         if (cnt++)    puts ("");
    41 
    42         int one = 0;
    43         for (int i=1234; i<=100000/n; ++i)
    44         {
    45             if (i * n > 98765)    break;
    46             if (ok (i, i*n) == true)
    47             {
    48                 printf ("%05d / %05d = %d
    ", n*i, i, n);    one++;
    49             }
    50         }
    51 
    52         if (!one)    printf ("There are no solutions for %d.
    ", n);
    53     }
    54 
    55     return 0;
    56 }
    57 
    58 
    59 /*
    60 There are no solutions for 61.
    61 */
    编译人生,运行世界!
  • 相关阅读:
    OpenCV特征描述
    OpenCV特征点检测
    expect实现无交互操作
    文件的修改时间
    sshd登录攻击
    tcp三次握手和syn 洪水攻击
    vim使用
    PHP拓展开发
    【转】LINUX 手动建立SWAP文件及删除
    Ubuntu下crontab命令的用法
  • 原文地址:https://www.cnblogs.com/Running-Time/p/4463227.html
Copyright © 2011-2022 走看看