結果

問題 No.2937 Sigma Plus Problem
ユーザー るこーそー
提出日時 2025-02-18 01:10:57
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,639 bytes
コンパイル時間 3,492 ms
コンパイル使用メモリ 278,208 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-02-18 01:11:02
合計ジャッジ時間 4,511 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int128 operator+(const int128&, const int128&)’:
main.cpp:19:72: warning: narrowing conversion of ‘(((__int128)a.int128::val) + ((__int128)b.int128::val))’ from ‘__int128’ to ‘long long int’ [-Wnarrowing]
   19 | int128 operator+(const int128 &a, const int128 &b){return int128{a.val + b.val};}
      |                                                                  ~~~~~~^~~~~~~
main.cpp: In function ‘int128 operator-(const int128&, const int128&)’:
main.cpp:20:72: warning: narrowing conversion of ‘(((__int128)a.int128::val) - ((__int128)b.int128::val))’ from ‘__int128’ to ‘long long int’ [-Wnarrowing]
   20 | int128 operator-(const int128 &a, const int128 &b){return int128{a.val - b.val};}
      |                                                                  ~~~~~~^~~~~~~
main.cpp: In function ‘int128 operator*(const int128&, const int128&)’:
main.cpp:21:72: warning: narrowing conversion of ‘(((__int128)a.int128::val) * ((__int128)b.int128::val))’ from ‘__int128’ to ‘long long int’ [-Wnarrowing]
   21 | int128 operator*(const int128 &a, const int128 &b){return int128{a.val * b.val};}
      |                                                                  ~~~~~~^~~~~~~
main.cpp: In function ‘int128 operator/(const int128&, const int128&)’:
main.cpp:22:72: warning: narrowing conversion of ‘(((__int128)a.int128::val) / ((__int128)b.int128::val))’ from ‘__int128’ to ‘long long int’ [-Wnarrowing]
   22 | int128 operator/(const int128 &a, const int128 &b){return int128{a.val / b.val};}
      |                                                                  ~~~~~~^~~~~~~

ソースコード

diff #

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

using ll=long long;
#define rep1(i,a) for(int i=0;i<(a);i++)
#define rep2(i,a,b) for(int i=(a);i<(b);i++) 
#define rep3(i,a,b,c) for(int i=(a);((a)<=(b)?i<(b):i>(b));i+=(c))
#define rep_overload(a,b,c,d,e,...) e
#define rep(...) rep_overload(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__)
#define chmax(x,y) ((x)=max(x,y))
#define chmin(x,y) ((x)=min(x,y))
#define all(x) (x).begin(),(x).end()

struct int128{
    __int128 val;
    int128() : val(0) {}
    int128(long long x) : val(x) {}
};
int128 operator+(const int128 &a, const int128 &b){return int128{a.val + b.val};}
int128 operator-(const int128 &a, const int128 &b){return int128{a.val - b.val};}
int128 operator*(const int128 &a, const int128 &b){return int128{a.val * b.val};}
int128 operator/(const int128 &a, const int128 &b){return int128{a.val / b.val};}
istream& operator>>(istream& in,int128 &x){
    string s;
    in >> s;
    __int128 res=0;
    bool is_neg=false;
    for (int i=0;i<s.size();i++){
        if (s[i]=='-')is_neg=true;
        else res=res*10 + (s[i]-'0');
    }
    if (is_neg)res=-res;
    x.val=res;
    return in;
}
ostream& operator<<(ostream& out,const int128 &x){
    __int128 n=x.val;
    if (n==0){
        out << "0";
        return out;
    }
    bool is_neg=(n<0);
    if (is_neg)n=-n;
    string s;
    while (n){
        s.push_back((n%10) + '0');
        n/=10;
    }
    if (is_neg)s.push_back('-');
    reverse(s.begin(),s.end());
    out << s;
    return out;
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int128 n;
    cin >> n;
    cout << n*(n+1)/2 << endl;
}
0