11 条题解

  • 1
    @ 2026-1-11 10:52:30

    sowater,c++用pow函数过不了,你用python啊,python有高精度啊

    a=int(input())
    b=2**a
    c=b-1
    print(c)
    
    
    
    
    • 1
      @ 2025-12-14 20:26:43
      #include<bits/stdc++.h>
      using namespace std;
      int a;
      int main(){
      	cin>>a;
      	long long b=pow(2,a)-1;
      	cout<<b;
      	return 0;
      }
      
      
      • 1
        @ 2025-12-13 13:07:34

        坑了我2次

        #include<bits/stdc++.h>
        #define int long long
        using namespace std;
        signed main()
        {
        	int n;
        	cin>>n;
        	cout<<(long long)(pow(2,n)-1);
        }
        
        • 1
          @ 2024-12-23 21:16:57

          下面那个,谁说pow会WA的???
          建立一个中转变量不就好了我才懒得写循环
          这种水题直接上代码: (忘记代码怎么加入,此处硬卡4min)

          #include<bits/stdc++.h>
          using namespace std;
          int a;
          int main(){
          	cin>>a;
          	long long b=pow(2,a)-1;
          	cout<<b;
          	return 0;
          }
          
          
          • 1
            @ 2024-12-22 11:03:52

            C++ :

            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
            	long long n,s=1,i,x=2;
            	cin>>n;
            	for(i=2;i<=n;i++)
            	{
            		s+=x;
            		x*=2;
            	}
            	cout<<s;
            	return 0;
            }
            

            Python :

            # coding=utf-8
            n=int(input())
            res=1
            xinz=2
            if n==1:
                print("1")
            else:
                for i in range(1,n):
                    res += xinz
                    xinz *= 2
                print(res)
            
            • 0
              @ 2025-11-16 10:53:44
              #include<bits/stdc++.h>
              using namespace std;
              signed main(){
              	ios::sync_with_stdio(0);cin.tie(0);
              	long long n,a=2;
              	cin>>n;
              	for(long long i=2;i<=n;i++){
              		a*=2;
              	}
              	cout<<a-1;
              	return 0;
              } 
              
              • 0
                @ 2024-12-27 21:12:52

                注意:此题直接使用 pow 由于精度问题只能得 50pts50pts,所以手敲:

                #include<bits/stdc++.h>
                #define int unsigned long long
                using namespace std;
                int qpow(int n){
                	int j=1;
                	for(int i=1;i<=n;i++)j*=2;
                	return j-1;
                }
                signed main(){
                	int n;
                	cin>>n;
                	cout<<qpow(n);
                }
                
                
                • -1
                  @ 2025-12-15 21:49:31
                  		for(int j=0;j<5;j++){
                  			cin >> a[i][j];
                  		}
                  	}
                  
                  
                  • -1
                    @ 2025-12-14 20:23:28

                    #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; long long a=1; long long ans=1; for(int i=2;i<=n;i++){ a*=2; ans+=a; } cout<<ans; return 0; }

                    • -2
                      @ 2024-12-22 18:47:30

                      甚至记得当年初级班的时候测试看到这题懵逼了半天。

                      顺带一提,他告诉你的是,每天浮萍增涨的数量,但是他问你的是浮萍的总数!!!!

                      #include<bits/stdc++.h>
                      using namespace std;
                      int main()
                      {
                      	int n;
                      	cin>>n;
                      	long long a=1;
                      	long long ans=1;
                      	for(int i=2;i<=n;i++)
                      	{
                      		a*=2;
                      		ans+=a;//算总数
                      	}
                      	cout<<ans;
                      	return 0;
                      }
                      
                      • -3
                        @ 2024-12-22 11:19:08

                        观察样例发现, 答案就是 2n12^n-1。但是直接用库函数pow会 WA,只能手写。

                        #include<bits/stdc++.h>
                        #define int long long
                        #define INF 0x3f3f3f
                        using namespace std;
                        int n,ans=1;
                        signed main(){
                        	cin>>n;
                        	for(int i=1;i<=n;i++)
                        		ans*=2;
                        	cout<<ans-1;
                        	return 0;
                        }
                        
                        • 1

                        信息

                        ID
                        6
                        时间
                        3000ms
                        内存
                        128MiB
                        难度
                        10
                        标签
                        递交数
                        652
                        已通过
                        0
                        上传者