5 条题解

  • 4
    @ 2024-10-24 19:38:54
    #include<iostream>
    using namespace std;
    typedef unsigned long long ull;
    ull a,b,p,res;
    int main()
    {
        cin>>a>>b>>p;
        while(b)
        {
            if(b&1) res = (res + a)%p;
            b = b / 2; 
            a = (a * 2)%p;
        }
        cout<<res;
    }
    
    
  • 1
    @ 2026-3-27 15:16:54
    #include <bits/stdc++.h>
    using namespace std;
    
    int main(){
    	long long a, b, p, sum = 0;
    	cin >> a >> b >> p;
    	while(b){
    		if(b & 1) sum = (sum + a) % p;
    		b >>= 1;
    		a = (a * 2) % p;
    	}
    	cout << sum % p;
    	return 0;
    }
    
    • 1
      @ 2025-5-17 19:24:12

      </u>#include using namespace std; typedef unsigned long long ull; ull a,b,p,res; int main() { cin>>a>>b>>p; while(b) { if(b&1) res = (res + a)%p; b = b / 2; a = (a * 2)%p; } cout<<res; }</u>

      • 1
        @ 2025-1-25 11:36:20
        ```
        #include<iostream>
        using namespace std;
        
        long long a, b, p, ans = 0;
        
        int main ()
        {
        	cin >> a >> b >> p;
        	while (b)
                {
        		if (b & 1) 
                        {
                              ans = (ans + a) % p;
                        }
        		a = (a * 2) % p;
        		b >>= 1;
        	}
        	cout << ans % p;
        }
        ```
        
        • -3
          @ 2024-11-19 20:21:46
          #include<bits/stdc++.h>
          using namespace std;
          long long a,b,p,ans=0;
          int main(){
          	cin >>a>>b>>p;
          	while(b){
          		if(b & 1) ans=(ans+a)%p;
          		a=(a*2)%p;
          		b>>=1;
          	}
          	cout<<ans%p;
          }
          
          • 1

          信息

          ID
          3
          时间
          1000ms
          内存
          128MiB
          难度
          7
          标签
          递交数
          2550
          已通过
          495
          上传者