/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 492.0 KiB
#3 Accepted 1ms 556.0 KiB
#4 Accepted 1ms 560.0 KiB
#5 Accepted 1ms 540.0 KiB
#6 Accepted 1ms 540.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define       ll           long long
#define       dub          double
#define       uint         unsigned long long
#define       CY           cout << "YES\n"
#define       CN           cout << "NO\n"
#define       pb           push_back
#define       ft           first
#define       sd           second
#define       srt(v)       sort(v.begin(), v.end())
#define       rsrt(v)      sort(v.rbegin(), v.rend())
const int m = 10;

//** Number theory --> begin

int gcd ( int a, int b )
{
    if ( b == 0 ) return a;
    else return gcd ( b, a%b );
}
int lcm ( int a, int b )
{
    return (a*b) / gcd(a, b);
}

int mod ( int a )
{
    return ( (a%m + m) % m );
}
int madd ( int a, int b )
{
    return mod ( mod(a)+mod(b) );
}
int mmul ( int a, int b )
{
    return mod ( mod(a)*mod(b) );
}

//** Number theory --> end


//** Bitwise --> begin

// swap ( x, y ) --> x=x^y, y=x^y, x=x^y
// if x=a then x=b // if x=b then x=a --> x=a^b^x
// a+b=(a^b)+2(a&b)
// a+b=(a|b)+(a&b)

bool odd ( int x )
{
    return (x & 1); // odd even check
}
bool checkkthbit ( int x, int k )
{
    return (x & (1<<k));  // k'th bit set or not
}
int setkthbit1 ( int x, int k )
{
    return (x | (1<<k));   // make k'th bit 1;
}
int setkthbit0 ( int x, int k )
{
    return (x &~ (1<<k));   // make k'th bit 0;
}
int mulnumby2powk ( int x, int k )
{
    return (x<<k);   // x*(pow(2,k))
}
int divnumby2powk ( int x, int k )
{
    return (x>>k);   // x/pow(2,k)
}
int noofsetbitint ( int x )
{
    return __builtin_popcount(x);  // int set bit count
}
int togglekthbit ( int x, int k )
{                          // if k = 0 then k = 1
    return (x ^ ( 1<<k ));  // if k = 1 then k = 0
}
bool powerof2 ( int x )
{
    return (x && !(x&(x-1))); // power of 2 checking
}

//** Bitwise --> end


void oddsum ( int a[], int x )
{
    int mio = INT_MAX;
    bool odd = false;
    int sm = 0;
    for ( int i=0; i<x; i++ ) {
        if ( a[i] > 0 ) sm += a[i];
        if ( (a[i] & 1) ) {
            odd = true;
            if ( mio > abs ( a[i] ) ) {
                mio = abs ( a[i] );
            }
        }
    }
    if ( !(sm & 1) ) sm -= mio;
    cout << sm << endl;
}

int bigm ( int b, int p, int m )
{
    if ( p == 0 ) return 1;
    else if ( !(p & 1) ) {
        int ea = b % m;
        int eb = ( bigm ( b, p-1, m ) ) % m;
        return (ea*eb) % m;
    }
    else {
        int ea = ( bigm( b, p/2, m ));
        return (ea*ea) % m;
    }
}

bool pr (int x)
{
    for (int i=2; i*i<=x; i++) {
        if (x % i == 0) return 0;
    }
    return 1;
}

void solve()
{
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    for (int i=1; i<=min(x, y); i++) {
        int s1 = x - i;
        int s2 = y - i;
        s1++;
        s2++;
        ans += (s1 * s2);
    }
    cout << ans << endl;
}

int main() {

        ios::sync_with_stdio(false);
        cin.tie(nullptr);

        int tc, cnt=1;
        solve();


 return 0;
}

Information

Submit By
Type
Submission
Problem
P1121 Square Counting Challenge
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 14:37:44
Judged At
2024-11-05 14:37:44
Judged By
Score
100
Total Time
2ms
Peak Memory
560.0 KiB