资讯详情

P1151 子数整数

题目描述

五位数a1a2a3a4a5.可分为三个子数:

sub1=a1a2a3

sub2=a2a3a4

sub3=a3a4a5

例如,5位数20207可以分割成

sub1=202

sub2=020(=20)

sub3=207

现在给定一个正整数KK,要求您在10000到30000之间编程所有满足以下条件的五位数,条件是这些五位数的三个子数sub1,sub2,sub3都可以被K整除。

输入格式

一个正整数K

输出格式

每种行为都有一个符合条件的五位数,需要从小到大的输出。不得重复输出或遗漏。如果没有解决方案,则输出No”。

输入输出样例

复制

15

复制

22555 25555 28555 30000

说明/提示

0<K<1000

#include <iostream> #include <math.h> #include <algorithm> #include <stack> #include <string.h> #include <vector> #include <cstring> using namespace std; int n,ans=0; int main() {     cin>>n;     for(int i=1;i<3;i  )     {         for(int j=0;j<10;j  )         {             for(int k=0;k<10;k  )             {                 for(int q=0;q<10;q  )                 {                     for(int w=0;w<10;w  )                     {                         int tmp1=i*100 j*10 k,tmp2=j*100 k*10 q,tmp3=k*100 q*10 w;                         if(tmp1%n==0&&tmp2%n==0&&tmp3%n==0)                         {                             ans=1;                             cout<<i<<j<<k<<q<<w<<endl;                         }                      }                 }             }         }     } if(300%n==0) {     ans=1;     cout<<30000<<endl; }     if(ans==0)         cout<<"No"<<endl;     return 0; }

标签: sub灯具电线连接器

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台