3788 - 寿司晚宴
Time Limit : 1 秒
Memory Limit : 10 MB

Input

Output

Examples
Input Format
10 10 3017196125 23051791739 1488181848717 197137375 3017196127 23051791739 197137372 3017196127 10519294081028 459742150225
Output Format
3 4 7 2 3 4 2 3 9 6
Solution C++
#include <cstdio> #include <iostream> #include <algorithm> #define rep(i,a,b) for(int i=a;i<=b;i++) #define dep(i,a,b) for(int i=a;i>=b;i--) using namespace std; typedef unsigned long long uLL; const int N = 100000; uLL a[N]; uLL F(uLL x){ uLL t = ((19 * x * x * x)+(98 * x * x))+((12 * x)+14); t = t * t * t; return t; } int ans[N]; int main(){ int n,q; scanf("%d%d",&n,&q); rep(i,1,q) scanf("%llu",&a[i]); rep(i,1,n) if (a[q] >> 26 == F(i) >> 26){ ans[q] = i; dep(i, q, 2) ans[i - 1] = a[i] ^ F(ans[i]); rep(i, 1, q) printf("%d\n",ans[i]); return 0; } return 0; }