/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Accepted 1ms 484.0 KiB
#5 Accepted 1ms 492.0 KiB
#6 Accepted 1ms 320.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 380.0 KiB
#9 Accepted 1ms 444.0 KiB
#10 Accepted 1ms 440.0 KiB

Code


/*
 *  Copyright (c) 2025 Parag Kishor Shornob
 *   All rights reserved.
 */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector< string > vi;
typedef pair<int,int> pii;

#define yes "YES\n"
#define no "NO\n"
#define pb push_back
#define pop pop_back
#define fastin ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define input(v) for(auto &i  : v) cin>>i;
#define all(x) (x).begin(),(x).end()

char ee = '\n';
void printVec(vector<string> &a){
    for(auto pp : a) cout<<pp <<" " ;
    cout<<ee;
}
ll power(ll base , ll exp){
    ll result=1;
    while(exp>0){
       if(exp%2==1){
        result *=base;
       }
       base  *=base ;
       exp/=2;

    }
    return result;

}

void  solve(){
    string s ; cin>>s ;
    string x,y;
    int k ;
    for(int i =0 ; ;i++){

        if ( s[i]!='+'){
            x.pb(s[i]);

            //break;
        }
         if( s[i]=='+'){
                k =i;
         break;
         }


    }
        for(int i =k+1 ; ;i++){
        if ( s[i]!='+'){
            y.pb(s[i]);

        }
        else
            break;
    }

    ll a=x[0]-'0' , b=y[0]-'0' ;
 for(int i =1;i<x.size();i++){
    a = a*10 + (x[i]-'0');
 }
  for(int i =1;i<y.size();i++){
    b = b*10 + (y[i]-'0');
 }
    ll n ; cin>>n ;
   ll ans =a;
    ll d= b-a;
    ll sum =a;
    ll div = b/a;


    if(a==b)
  {
        for(int i = 1 ; i<n ;i++){
            sum+=ans;
        }
    }
    else{

    for(int i = 1 ; i<n ; i++){

        ans  +=d ;
    sum+=ans;


       }
    }




//cout<<x<<" " <<y<< " "<< "" <<ee;




   cout<<sum<<ee;


}

signed main() {
    fastin;
    ll tt=1 ;
   //cin>> tt;
    while(tt--) solve();


}

Information

Submit By
Type
Submission
Problem
P1231 Busy Friend
Contest
LUCC Presents Kick & Code Intra LU Programming Contest
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 07:44:31
Judged At
2025-09-01 07:44:31
Judged By
Score
100
Total Time
1ms
Peak Memory
532.0 KiB