답안 #874129

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874129 2023-11-16T09:45:05 Z Kakarot 나머지들의 합 (NOI12_modsum) C++
25 / 25
83 ms 536 KB
#include <bits/stdc++.h>
#define int long long
#define vi vector<int>
#define vii vector<pair<int,int>>
#define len(a) (int)a.size()
using namespace std;

void setIO() {
  cin.tie(0)->ios_base::sync_with_stdio(0);
}

int f(vi &a) {
  int x = accumulate(a.begin(),a.end(),0LL);
  return (x*x*x*x + 2*x*x) % 5 + 1;
}

void recursive_helper(int index, vi &current_values, vii &range, int &total_sum) {
  if(index == len(current_values)) {
    total_sum += f(current_values);
  }
  else {
    for(int x = range[index].first;x <= range[index].second;++x) {
      current_values[index] = x;
      recursive_helper(index + 1,current_values,range,total_sum);
    }
  }
}

void solve() {
  int n,ans = 0;
  cin >> n;
  vii range(n);
  for(auto &x : range) cin >> x.first >> x.second;
  vi current_values(n);
  recursive_helper(0,current_values,range,ans);
  cout << ans << '\n';
}

int32_t main() {
  setIO();
  solve();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 536 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 4 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 448 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 10 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 74 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 83 ms 348 KB Output is correct