Test instructions: Give a number n and ask if n can be the product of the number of Fibonacci sequences
First brush the Fibonacci sequence, then enumerate
1#include <cstdio>2#include <cstring>3#include <queue>4#include <map>5#include <iostream>6 using namespacestd;7typedefLong LongLL;8 ConstLL Max =1000000000;9LL num[ -];TenMap<ll,BOOL>m; One voidInit () A { -Queue<ll>Q; -m[0] =true; them[1] =true; -num[0] =0; -num[1] =1; - for(inti =2; I < $; i++) + { -Num[i] = num[i-1] + num[i-2]; + Q.push (Num[i]); Am[Num[i]] =true; at } - while(!q.empty ()) - { - inttemp =Q.front (); - Q.pop (); - for(inti =1; I < $; i++) in { -LL res = temp *Num[i]; to if(Res >Max) + Break; - if(m[res]) the Continue; *m[res] =true; $ Q.push (res);Panax Notoginseng } - } the + } A intMain () the { + init (); - inttest, N; $scanf"%d", &test); $ while(test--) - { -scanf"%d", &n); the if(m[n]) -printf"yes\n");Wuyi Else theprintf"no\n"); - } Wu return 0; -}View Code
HDU 5167 (map + violence)