제출 #976287

#제출 시각아이디문제언어결과실행 시간메모리
976287vjudge1Trol (COCI19_trol)C++17
10 / 50
3 ms2140 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int maxn=1e5; int arr[maxn]; void buat1(int &n){ int sum=0; while(n!=0){ sum= sum+ (n%10); n/=10; } n=sum; } void pre_compute(){ for(int i=0; i<=maxn; i++){ int keepi=i; while(keepi - 10 >= 0){ buat1(keepi); }arr[i] = keepi; } } signed main(){ memset(arr,0,sizeof(arr)); pre_compute(); int q; cin >> q; while(q--){ int l,r; cin >> l>> r; int sum=0; for(int i=l; i<=r ;i++){ sum+=arr[i]; } cout << sum<<"\n"; } }

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

trol.cpp: In function 'void pre_compute()':
trol.cpp:20:10: warning: iteration 100000 invokes undefined behavior [-Waggressive-loop-optimizations]
   20 |  }arr[i] = keepi;
      |   ~~~~~~~^~~~~~~
trol.cpp:16:16: note: within this loop
   16 |  for(int i=0; i<=maxn; i++){
      |               ~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...