4 条题解

  • 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
      @ 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;
      }
      ```
      
      • 0
        @ 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
          @ 2024-10-25 19:56:19

          666

          • 1

          信息

          ID
          3
          时间
          1000ms
          内存
          128MiB
          难度
          8
          标签
          递交数
          2138
          已通过
          398
          上传者