제출 #1266432

#제출 시각아이디문제언어결과실행 시간메모리
1266432ilovewaguriMultiplication (BOI24_multiplication)C++20
99 / 100
1 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define NAME "Multiplication"
#define nl '\n'
#define allofa(x,sz) x,x+sz+1
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define mset(x,val) memset(x,val,sizeof(x))
#define couf(x) cout << fixed << setprecision(x)
template<class T> T Abs(T &x) {return (x>=0 ? x : -x);};
template<class X,class Y> bool minimize(X &a, Y b){if(a>b) {a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b) {a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const ll LINF = (long long)1e15;
const int INF = (int)1e9;

void ccps() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    if(fopen(NAME".inp","r")) {
        freopen(NAME".inp","r",stdin);
        freopen(NAME".out","w",stdout);
    }
}

ll indianMul(ll x, ll y) {
    if(y==0) return 0LL;
    if(y==1) return x;
    ll tmp = indianMul(x,y/2);
    if(y%2==0) return (tmp%mod + tmp%mod)%mod;
    return (tmp%mod + (tmp%mod + x%mod)%mod)%mod;
}

signed main() {
    ccps();
    int n; cin >> n;
    ll res = 1;
    for (int i = 1; i<=n; i++) {
        int x; cin >> x;
        res = indianMul(res,x);
    }
    cout << res;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void ccps()':
Main.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(NAME".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(NAME".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...