11 条题解

  • 1

    这题应该是有点问题,公式样例没过其他都过了,我卡了一下样例对了:

    真正的AC代码:

    # include<iostream>
    # include<math.h>
    using namespace std;
    int main()
    {
        int n,sum;
        cin>>n;
        if(n==2)//卡样例
        {
     	   cout<<7;
     	   return 0;
        }
        sum = (int)pow(n,n)-(n-1);//公式
        cout<<sum;
        return 0;
    }
    

    哪位高人可以指导一下,发一下此题正解(最好有注释),感激不尽🎉️

    • 正解来了!!!!!!!!!

      谢老师指导!

      #include<stdio.h>
      #include<iostream>
      using namespace std;
      int main()
      {
          int n ;
          cin >> n;
          int num = 1;
          int flag = 0;
          while(flag == 0)
          {
              int sum = num * (n-1);
              int k = 1;
              for(int i = 1;i <= n; i++)
              {
                  if(sum%(n-1) != 0)
                  {
                      k = 0;
                      break;
                  }
                  sum = sum/(n-1)*n+1;
              }
              if(k == 1)
              {
                  cout << sum;
                  break;
              }
              num++;
          }
          return 0;
      }
      
  • 0
    @ 2024-6-14 20:11:34

    //答案:

    #include <bits/stdc++.h>
    using namespace std;
    int n,a,i = 1,b;
    bool l = false;
    int main(){
    	cin >> n;
    	while(!l){
    		a = i;
    		for(int j = 1 ; j <= n ; j++){
    			b = a - 1;
    			if(a % n != 1 || b <= 0){
    				l = false;
    				break;
    			}
    			a = (a - 1) / n * (n - 1);
    			l = true;
    		}
    		i++;
    	}
    	i--;
    	cout << i << endl;
    	return 0;
    }
    
    
    • 0
      @ 2024-6-14 20:10:18
      #include <bits/stdc++h>
      using namespace std;
      int n,a,i = 1,b;
      bool l = false;
      int main(){
      	cin >> n;
      	while(!l){
      		a = i;
      		for(int j = 1 ; j <= n ; j++){
      			b = a - 1;
      			if(a % n != 1 || b <= 0){
      				l = false;
      				break;
      			}
      			a = (a - 1) / n * (n - 1);
      			l = true;
      		}
      		i++;
      	}
      	i--;
      	cout << i << endl;
      	return 0;
      }
      
      ## 大家好,考大家智商喽! 这道题拿错了?(看看哪个老六会直接复制)
      
      • 0
        @ 2024-5-20 22:35:59

        啊哈哈哈题解来咯

        #include <bits/stdc++.h>
        using namespace std;
        int n,a,i = 1,b;
        bool l = false;
        int main(){
        	cin >> n;
        	while(!l){
        		a = i;
        		for(int j = 1 ; j <= n ; j++){
        			b = a - 1;
        			if(a % n != 1 || b <= 0){
        				l = false;
        				break;
        			}
        			a = (a - 1) / n * (n - 1);
        			l = true;
        		}
        		i++;
        	}
        	i--;
        	cout << i << endl;
        	return 0;
        }
        
        • 0
          @ 2023-7-8 9:14:53

          根本不会

          • 0
            @ 2023-7-6 21:28:21
            怎么写吖
            
            • 0
              @ 2023-7-6 21:27:55

              怎么写啊!

              • 0
                @ 2023-6-19 23:58:32

                😕 ........................................

                • 0
                  @ 2023-4-3 17:05:27

                  6

                  • 0
                    @ 2023-3-26 18:07:14

                    ;

                    • -2
                      @ 2023-5-13 22:36:00
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      ```
                      
                      
                      • 1

                      信息

                      ID
                      1505
                      时间
                      1000ms
                      内存
                      256MiB
                      难度
                      8
                      标签
                      递交数
                      323
                      已通过
                      54
                      上传者