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;
    }
    
    
  • 3
    @ 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;
    }
    ```
    
    • 1
      @ 2025-4-21 20:24:28
      ```cpp
      #include <bits/stdc++.h>
      using namespace std;
      #define LL long long
      const int N = 1e5 + 10;
      const int INF = 0x3f3f3f3f;
      long long 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;
      }
      //菜鸟驿站
      //老六专属
      
      
      • 0
        @ 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
          @ 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
          难度
          8
          标签
          递交数
          2290
          已通过
          428
          上传者