5 条题解

  • 9
    @ 2022-8-2 10:31:33

    数据不大,适合打表//娱乐用

    #include <cstdio>
    using namespace std;
    int a[150] , l , r ;
    void get(){//打表,就100多个数罢了,枚举所有可行的数
    	a[0] = 1017 , a[1] = 1023 , a[2] = 1024 , a[3] = 1027 , a[4] = 1028 ;
    	a[5] = 1036 , a[6] = 1037 , a[7] = 1042 , a[8] = 1113 , a[9] = 1117 ;
    	a[10] = 1164 , a[11] = 1175 , a[12] = 1176 , a[13] = 1197 , a[14] = 1228 ;
    	a[15] = 1267 , a[16] = 1268 , a[17] = 1277 , a[18] = 1302 , a[19] = 1307 ;
    	a[20] = 1323 , a[21] = 1328 , a[22] = 1343 , a[23] = 1352 , a[24] = 1355 ;
    	a[25] = 1375 , a[26] = 1395 , a[27] = 1405 , a[28] = 1428 , a[29] = 1433 ;
    	a[30] = 1441 , a[31] = 1442 , a[32] = 1444 , a[33] = 1463 , a[34] = 1541 ;
    	a[35] = 1593 , a[36] = 1594 , a[37] = 1628 , a[38] = 1646 , a[39] = 1648 ;
    	a[40] = 1701 , a[41] = 1706 , a[42] = 1746 , a[43] = 1791 , a[44] = 1816 ;
    	a[45] = 1866 , a[46] = 1873 , a[47] = 1896 , a[48] = 1903 , a[49] = 1921 ;
    	a[50] = 1936 , a[51] = 1949 , a[52] = 1953 , a[53] = 1964 , a[54] = 1976 ;
    	a[55] = 1991 , a[56] = 1996 , a[57] = 2013 , a[58] = 2027 , a[59] = 2069 ;
    	a[60] = 2095 , a[61] = 2123 , a[62] = 2126 , a[63] = 2175 , a[64] = 2199 ;
    	a[65] = 2203 , a[66] = 2277 , a[67] = 2301 , a[68] = 2304 , a[69] = 2311 ;
    	a[70] = 2321 , a[71] = 2322 , a[72] = 2326 , a[73] = 2339 , a[74] = 2382 ;
    	a[75] = 2396 , a[76] = 2401 , a[77] = 2414 , a[78] = 2439 , a[79] = 2493 ;
    	a[80] = 2507 , a[81] = 2509 , a[82] = 2527 , a[83] = 2528 , a[84] = 2529 ;
    	a[85] = 2547 , a[86] = 2552 , a[87] = 2553 , a[88] = 2557 , a[89] = 2595 ;
    	a[90] = 2599 , a[91] = 2618 , a[92] = 2672 , a[93] = 2684 , a[94] = 2686 ;
    	a[95] = 2699 , a[96] = 2701 , a[97] = 2711 , a[98] = 2727 , a[99] = 2731 ;
    	a[100] = 2801 , a[101] = 2802 , a[102] = 2821 , a[103] = 2825 , a[104] = 2866 ;
    	a[105] = 2882 , a[106] = 2884 , a[107] = 2905 , a[108] = 2911 , a[109] = 2927 ;
    	a[110] = 2929 , a[111] = 2931 , a[112] = 2945 , a[113] = 2984 , a[114] = 2992 ;
    	a[115] = 3018 , a[116] = 3041 , a[117] = 3042 , a[118] = 3059 , a[119] = 3094 ;
    	a[120] = 3105 , a[121] = 3111 , a[122] = 3142 ; 
    }
    int main(){
    	scanf("%d%d",&l,&r);
    	get();
    	for(int i = 0 ; a[i] <= r ; i ++)
    		if(a[i] >= l)
    			printf("%d\n",a[i]) ;//输出!
    	/*freopen("a.txt","w", stdout);//打表代码,保存在"a.txt" 不会真有人手打吧
    	int m = 0 ;
    	for(int i = 1000 ; i <= 9999 ; i ++){
    		long x = i * i ;
    		int a[10] = {};
    		if(x >= 10000000)
    			break ;
    		while(x){
    			a[x%10] ++ ;
    			if(a[x%10] > 1)
    				break ;
    			x /= 10 ;
    		}
    		if(!x){
    			printf("a[%d] = %d ", m ++ , i) ;
    			if(m % 5 == 0)
    				printf(";\n	") ;
    			else
    				printf(", ") ;
    		}
    	}*/
    	
    	return 0 ;
    }
    
  • 0
    @ 2023-8-21 19:57:36
    #include <bits/stdc++.h>
    using namespace std;
    bool nna(int dude)
    {
        int lll = dude * dude;
        int a[10];
        for (int i = 1 ; i <= 7 ; i++)
        {
            a[i] = lll % 10;
            lll /= 10;
        }
        int sum = true;
        int cnt = 0;
        
        
        for (int i = 1 ; i <= 7 ; i++)
        {
            for(int j = 1 ; j <= 7 ; j++)
            {
                if (a[i] == a[j])
                {
                    cnt++;
                }
            }
            if (cnt == 7)
            {
                sum = false;
            }
            else
            {
                sum = true;
            }
        }
        return sum;
    }
    int main()
    {
        int x , y;
        cin >> x >> y;
        for (int i = x ; i <= y ; i++)
        {
            if(nna(i) == false)
            {
                cout << i << endl;
            }
        }
        return 0;
    }
    
    • 0
      @ 2023-7-8 12:50:30
      #include <iostream>
      #include <cmath>
      using namespace std;
      void judge(int i)
      {
      	int a[7];
      	int g = i * i;
      	int work = 1;
      	if (i * i / 1000000 != 0)//一定要是七位数
      	{
      		for (int j = 0; j < 7; j++)
      		{
      			a[j] = (g - g / (int)pow(10, j+1) * (int)pow(10, j+1)) / (int)pow(10, j);//获取各个数位,可以参考1083回文数
      		}
      		for (int i = 0; i < 7; i++)
      		{
      			for (int j = i + 1; j < 7; j++)
      			{
      				if (a[i] == a[j])
      				{
      					work = 0;
      				}
      			}
      		}
      		if (work == 1)
      		{
      			cout << i << endl;
      		}
      	}
      }
      int main() 
      {
      	int a, b;
      	cin >> a >> b;
      	for (int i = a; i <= b; i++)
      	{
      		judge(i);
      	}
      	return 0;
      }
      
      • 0
        @ 2023-6-29 17:25:27
        //简单枚举
        #include <bits/stdc++.h>
        using namespace std;
        bool f(int x){
            bool vis[10]={};
            while (x){//判断是否有重复的数位
                if (vis[x%10]){
                    return 0;
                }
                vis[x%10]=1;
                x/=10;
            }
            return 1;
        }
        int main(){
            int x,y;
            cin>>x>>y;
            for (int i=x;i<=y;i++){
                if (10000000>i*i&&i*i>999999&&f(i*i)){
                    cout<<i<<endl;
                }
            }
            return 0;
        }
        
        • 0
          @ 2023-4-10 21:18:52

          简朴的代码

          #include<bits/stdc++.h>
          using namespace std;
          int x,y,a[10];
          void awa()
          {
              for (int i=0;i<=9;i++)
                  a[i]=0;
              return;
          }
          bool qwq()
          {
              for (int i=0;i<=9;i++)
                  if (a[i]>1)
                      return 0;
              return 1;
          }
          int main()
          {
              cin>>x>>y;
              for (int i=x;i<=y;i++)
              {
                  if (i*i<1000000||i*i>9999999)
                      continue;
                  awa();
                  a[(i*i)/1000000]++,a[(i*i)/100000%10]++,a[(i*i)/10000%10]++,a[(i*i)/1000%10]++,a[(i*i)/100%10]++,a[(i*i)/10%10]++,a[(i*i)%10]++;
                  if (qwq())
                      cout<<i<<'\n';
              }
              return 0;
          }
          • 1

          【基础】既生瑜,何生亮!

          信息

          ID
          118
          时间
          1000ms
          内存
          64MiB
          难度
          2
          标签
          递交数
          193
          已通过
          122
          上传者