이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add (int a, int b) {
a += b; if (a >= MOD) a -= MOD;
return a;
}
int sub (int a, int b) {
a -= b; if (a < 0) a += MOD;
return a;
}
int mul (int a, int b) {
return (a * 1ll * b) % MOD;
}
const int MAXN = 5e5 + 25;
int x[MAXN], y[MAXN], n;
int ans () {
long double s = log2(x[0]);
long double cur = s + log2(y[0]);
int pos = 0;
for (int i = 1; i < n; i++) {
s += log2(x[i]);
long double t = s + log2(y[i]);
if (t > cur + 1e-9) {
cur = t; pos = i;
}
}
int ret = 1;
for (int i = 0; i <= pos; i++) {
ret = mul(ret, x[i]);
}
ret = mul(ret, y[pos]);
return ret;
}
int init (int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < n; i++) {
x[i] = X[i]; y[i] = Y[i];
}
return ans();
}
int updateX (int pos, int val) {
x[pos] = val;
return ans();
}
int updateY (int pos, int val) {
y[pos] = val;
return ans();
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int mul(int, int)':
horses.cpp:14:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
14 | return (a * 1ll * b) % MOD;
| ~~~~~~~~~~~~~~^~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |