From ef1992fa9ea16d09a9306e7f14ad80c8315a0873 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 17 Sep 2016 22:03:49 +0800 Subject: [PATCH] Create 5878_chouti.cpp From http://www.cnblogs.com/chouti/p/5879804.html --- HDOJ/5878_chouti.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 HDOJ/5878_chouti.cpp diff --git a/HDOJ/5878_chouti.cpp b/HDOJ/5878_chouti.cpp new file mode 100644 index 0000000..a50bd98 --- /dev/null +++ b/HDOJ/5878_chouti.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +#define inf 1001001001 +#define infll 1001001001001001001LL +#define ll long long +#define dbg(vari) cerr<<#vari<<" = "<<(vari)< +il int read(){ + bool f=true;Ri x=0;char ch;while(!isdigit(ch=gc))if(ch=='-')f=false;while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-'0';ch=gc;}return f?x:-x; +} +#define gi read() +ll p[10000],_p; +setq; +int main(){ + q.insert(1); + int cnt=0; + while(!q.empty()){ + p[++_p]=*q.begin(); + q.erase(p[_p]); + ll t=p[_p]; + if(t>1000000000){break;} + if(2*t<=1000000000)q.insert(2*t); + if(3*t<=1000000000)q.insert(5*t); + if(5*t<=1000000000)q.insert(3*t); + if(7*t<=1000000000)q.insert(7*t); + } + int T=gi; + while(T--){ + int n=gi; + int pos = lower_bound(p+1, p+_p+1, n) - p; + printf("%I64d\n", p[pos]); + } +}