洛谷_P1008 [NOIP1998 普及组] 三连击_枚举

洛谷_P1008 [NOIP1998 普及组] 三连击_枚举

//
#include<bits/stdc++.h>
using namespace std;

bool f( int in )
{
    int cnt[11];
    memset( cnt,0,sizeof( cnt ) );

    int a=in,b=2*in,c=3*in;
    while( a ) { cnt[a%10]++; a/=10; }
    while( b ) { cnt[b%10]++; b/=10; }
    while( c ) { cnt[c%10]++; c/=10; }
    
    for( int i=1;i<=9;i++ )
        if( cnt[i]!=1 ) return false;
    return true;
}

int main()
{
    for( int i=123;i<333;i++ )
        if( f( i ) )
            cout<<i<<" "<<2*i<<" "<<3*i<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_63173957/article/details/125480488