Submission #64509085


Source Code Expand

Copy
#include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define ll long long
#define N 10000000
#define LOGN 19
#define MAXLL 1e18L
#define MO 998244353
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <numeric>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <map>
#include <set>
#include <tuple>
using namespace std;

#define ll long long
#define N 10000000
#define LOGN 19

#define MAXLL 1e18L
#define MO 998244353
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define ANS(f) \
    if (f)     \
        YES;   \
    else       \
        NO

ll T;

class Sum
{
public:
    Sum()
    {
    }

    Sum(int n)
    {
        this->n = n;
        this->t.assign(n, 0);
    }

    int getSum(int r)
    {
        int result = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1)
            result += t[r];
        return result;
    }

    int getSum(int l, int r)
    {
        return getSum(r) - getSum(l - 1);
    }

    void inc(int i)
    {
        for (; i < n; i = (i | (i + 1)))
            t[i]++;
    }

    int n;
    vector<int> t;
};

void solve()
{
    ll n, m;
    cin >> n >> m;

    ll x = 1;
    ll ans = 0;

    for (int i = 0; i <= m; i++)
    {
        ans += x;
        if (ans > 1000000000)
        {
            cout << "inf" << endl;
            return ;
        }
        x = x * n;        
    }
    cout << ans << endl;
}

int main()
{
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    srand((unsigned)time(0));

    //    cin >> T;
    T = 1;
    while (T--)
    {
        solve();
    }

    return 0;
}

Submission Info

Submission Time
Task B - Sum of Geometric Series
User Vladl1313
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1612 Byte
Status AC
Exec Time 1 ms
Memory 3728 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 37
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt, sample03.txt
All sample00.txt, sample01.txt, sample02.txt, sample03.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt, testcase32.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3540 KB
sample01.txt AC 1 ms 3596 KB
sample02.txt AC 1 ms 3596 KB
sample03.txt AC 1 ms 3660 KB
testcase00.txt AC 1 ms 3600 KB
testcase01.txt AC 1 ms 3724 KB
testcase02.txt AC 1 ms 3660 KB
testcase03.txt AC 1 ms 3468 KB
testcase04.txt AC 1 ms 3660 KB
testcase05.txt AC 1 ms 3564 KB
testcase06.txt AC 1 ms 3660 KB
testcase07.txt AC 1 ms 3572 KB
testcase08.txt AC 1 ms 3536 KB
testcase09.txt AC 1 ms 3728 KB
testcase10.txt AC 1 ms 3668 KB
testcase11.txt AC 1 ms 3540 KB
testcase12.txt AC 1 ms 3536 KB
testcase13.txt AC 1 ms 3528 KB
testcase14.txt AC 1 ms 3656 KB
testcase15.txt AC 1 ms 3532 KB
testcase16.txt AC 1 ms 3548 KB
testcase17.txt AC 1 ms 3652 KB
testcase18.txt AC 1 ms 3596 KB
testcase19.txt AC 1 ms 3672 KB
testcase20.txt AC 1 ms 3604 KB
testcase21.txt AC 1 ms 3676 KB
testcase22.txt AC 1 ms 3656 KB
testcase23.txt AC 1 ms 3544 KB
testcase24.txt AC 1 ms 3580 KB
testcase25.txt AC 1 ms 3536 KB
testcase26.txt AC 1 ms 3552 KB
testcase27.txt AC 1 ms 3656 KB
testcase28.txt AC 1 ms 3544 KB
testcase29.txt AC 1 ms 3540 KB
testcase30.txt AC 1 ms 3664 KB
testcase31.txt AC 1 ms 3476 KB
testcase32.txt AC 1 ms 3540 KB


2025-04-11 (Fri)
09:43:06 +00:00