全部评论 7

  • #include <bits/stdc++>
    using namespace std;
    int main()
    {
        const int target = 20;
        int ans = 0;
        for (int c1 = 0; c1 <= 3; c1++)
        for (int c2 = 0; c2 <= 3; c2++)
        for (int c3 = 0; c3 <= 3; c3++)
        for (int c4 = 0; c4 <= 3; c4++)
        for (int c5 = 0; c5 <= 3; c5++)
        for (int c6 = 0; c6 <= 3; c6++)
        for (int c7 = 0; c7 <= 3; c7++)
        for (int c8 = 0; c8 <= 3; c8++)
        for (int c9 = 0; c9 <= 3; c9++)
        for (int c10 = 0; c10 <= 3; c10++)
        for (int c11 = 0; c11 <= 3; c11++)
        for (int c12 = 0; c12 <= 3; c12++)
        for (int c13 = 0; c13 <= 3; c13++)
        for (int c14 = 0; c14 <= 3; c14++)
        for (int c15 = 0; c15 <= 3; c15++)
        {
            // 15种钱币面额:1、2、3、4……15
            int sum = c1*1 + c2*2 + c3*3 + c4*4 + c5*5
                    + c6*6 + c7*7 + c8*8 + c9*9 + c10*10
                    + c11*11 + c12*12 + c13*13 + c14*14 + c15*15;
            if (sum == target)
            {
                ans++;
            }
        }
    
        cout << "凑出" << target << "元的方案总数:" << ans<< endl;
        return 0;
    }
    

    2天前 来自 江苏

    1
  • 爆搜的话我写过九层

    #include <bits/stdc++.h>
    using namespace std;
    
    int main() {
        string s;
        cin >> s;
        int cnt = 0;
        for (int a = '0'; a <= '9'; a++) {
        	for (int b = '0'; b <= '9'; b++) {
        		for (int c = '0'; c <= '9'; c++) {
        			for (int d = '0'; d <= '9'; d++) {
        				for (int e = '0'; e <= '9'; e++) {
        					for (int f = '0'; f <= '9'; f++) {
        						for (int g = '0'; g <= '9'; g++) {
        							for (int h = '0'; h <= '9'; h++) {
        								if (a != b && a != c && a != d && a != e && a != f && a != g && a != h
    									 && b != c && b != d && b != e && b != f && b != g && b != h
    									 && c != d && c != e && c != f && c != g && c != h
    									 && d != e && d != f && d != g && d != h
    									 && e != f && e != g && e != h
    									 && f != g && f != h
    									 && g != h) {
    									 	cnt++;
    									 	if (s[0] != a) continue;
    									 	if (s[1] != b) continue;
    									 	if (s[2] != c) continue;
    									 	if (s[3] != d) continue;
    									 	if (s[4] != e) continue;
    									 	if (s[5] != f) continue;
    									 	if (s[6] != g) continue;
    									 	if (s[7] != h) continue;
    									 	cout << cnt;
    									 	return 0;
    									}
    								}
    							}
    						} 
    					}
    				}
    			}
    		} 
    	}
        return 0;
    }

    2天前 来自 上海

    1
  • 如果说是实际题目,我最多写过四层,如果不是你让我写多少层我就写多少层

    1周前 来自 浙江

    0
  • 二三怎么就垃圾了,差评

    1周前 来自 浙江

    0
  • 我最多就2

    1周前 来自 浙江

    0
  • #include <bits/stdc++.h>
    using namespace std;
    int n,c=0,a[100][10000];
    int main()
    {
    	cin>>n;
    	if(n>=10&&n<=30)
    	{
    		for(int o=1;o<=3;o++)
    		{
    			for(int p=1;p<=3;p++)
    			{
    				for(int q=1;q<=3;q++)
    				{
    					for(int r=1;r<=3;r++)
    					{
    						for(int s=1;s<=3;s++)
    						{
    							for(int t=1;t<=3;t++)
    							{
    								for(int u=1;u<=3;u++)
    								{
    									for(int v=1;v<=3;v++)
    									{
    										for(int w=1;w<=3;w++)
    										{
    											for(int x=1;x<=3;x++)
    											{
    												if(o+p+q+r+s+t+u+v+w+x==n)
    												{
    													c++;
    													a[1][c]=o;
    													a[2][c]=p;
    													a[3][c]=q;
    													a[4][c]=r;
    													a[5][c]=s;
    													a[6][c]=t;
    													a[7][c]=u;
    													a[8][c]=v;
    													a[9][c]=w;
    													a[10][c]=x;
    												}
    											}
    											
    										}
    									}
    								}
    							}
    						}
    					}
    				}
    			}
    		}
    		cout<<c<<"\n";
    		for(int i=1;i<=c;i++)
    		{
    			for(int j=1;j<=10;j++)
    			{
    				cout<<a[j][i]<<" ";
    			}
    			cout<<"\n";
    		}
    	}
    	else cout<<"0";
    	return 0;
    }
    

    1周前 来自 浙江

    0
  • n2怎么你了

    2026-04-25 来自 广东

    0
    • 我反感QAQ

      2026-04-25 来自 江苏

      1

热门讨论