제출 #1096384

#제출 시각아이디문제언어결과실행 시간메모리
1096384slah007Weird Numeral System (CCO21_day1problem2)C++17
0 / 25
1 ms344 KiB
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <cassert> #include <set> #include <map> using namespace std; const int MAXK = 1e6; const int MAXM = 2500; const int MAXD = MAXM<<1|1; int K, Q, D, M; set<int> digits; map<long long, int> dp; bool go(long long n){ if(dp.count(n)) return dp[n]; if(digits.count(n)){ printf("%lld ", n); return dp[n] = 1; } dp[n] = 0; for(auto x : digits){ if((n-x)%K == 0){ long long t = (n-x)/K; if(go(t)){ printf("%d ", x); return dp[n] = 1; } } } return dp[n]; } int main(){ scanf("%d %d %d %d", &K, &Q, &D, &M); for(int i=0;i<D;i++){ int x; scanf("%d", &x); digits.insert(x); } while(Q--){ long long n; scanf("%lld", &n); //dp.clear(); if(!go(n)){ puts("IMPOSSIBLE"); } else{ puts("0"); } } return 0; }

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

Main.cpp: In function 'bool go(long long int)':
Main.cpp:22:22: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |         return dp[n] = 1;
Main.cpp:30:30: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |                 return dp[n] = 1;
Main.cpp: In function 'int main()':
Main.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d %d %d %d", &K, &Q, &D, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
Main.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         scanf("%lld", &n);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...