Hrbust 2093 真·找规律

真•找规律

Time Limit: 500 MS Memory Limit: 65536 K

Total Submit: 1431(910 users) Total Accepted: 1059(880 users) Rating: Special Judge: No

Description

传说大家最喜欢找规律了是不是。 _
参见附表,表中都是5位数,他们有很强烈的规律性呦~当然他们肯定不止这么多。
请找出所有符合这样规律的五位数(不含前导0,比如不能是00000),从小到大将他们全部输出。

下表是 30个具有规律性的数字。

48032

34012

77749

48932

48732

24308

35015

48132

31403

48432

44816

48332

63518

53615

19009

87656

37621

30500

51205

80900

18308

48232

95545

48832

59145

48632

77449

63218

42108

48532

Input

没有Input 。

Output

从小到大输出所有存在规律的数字。

Source

哈尔滨理工大学第四届ACM程序设计竞赛(同步赛)

题解

规律就是一个五位数的后两位数字等于前两个数的乘积...代码如下:

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <set>
#include <algorithm>

using namespace std ;

int main(){
    for ( int i = 10000 ; i <= 99999 ; i ++ ){
        int x = i ;
        int one = x % 10 ;
        x /= 10 ;
        int two = x % 10 ;
        x /= 100 ;
        int index_one = x % 10 ;
        x /= 10 ;
        int index_two = x % 10 ;
        if ( index_one * index_two == two * 10 + one ){
            printf("%d\n" , i) ;
        }
    }
    return 0 ;
}
posted @ 2018-11-04 22:58  Cantredo  阅读(153)  评论(0编辑  收藏  举报