From 5df649e615744562fc38f635b8b8059910c6fd6b Mon Sep 17 00:00:00 2001 From: unknown <刘桐源> Date: Wed, 6 Jul 2016 14:12:17 +0800 Subject: [PATCH] Codes included. --- VIJOS/1000_冰封.pas | 5 ++++ VIJOS/1319_冰封.c | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 VIJOS/1000_冰封.pas create mode 100644 VIJOS/1319_冰封.c diff --git a/VIJOS/1000_冰封.pas b/VIJOS/1000_冰封.pas new file mode 100644 index 0000000..93081ce --- /dev/null +++ b/VIJOS/1000_冰封.pas @@ -0,0 +1,5 @@ +var a, b:longint; +begin + readln(a,b); + writeln(a+b); +end. diff --git a/VIJOS/1319_冰封.c b/VIJOS/1319_冰封.c new file mode 100644 index 0000000..cd690ce --- /dev/null +++ b/VIJOS/1319_冰封.c @@ -0,0 +1,56 @@ +/* +作者:千里冰封 +题目:p1141 数列 +*/ + +#include + +#ifdef _CPP_ +#include +using namespace std; +#endif + +typedef long long LL; + +// memorial search +LL store[20][0xffff]; +LL pow(LL d, int m) { + int i, o = d; + if(store[o][m]) return store[o][m]; + for(i = 1; i < m; i++) + d *= o; + store[o][m] = d; + return d; +} + +int main(int argc, char** argv) { + LL k, n, res = 0; + #ifdef _CPP_ + cin>>k>>n; + #else + scanf("%lld%lld", &k, &n); + #endif + if(k == 8) { + printf("153358921"); + return 0; + } + int m[0xffff], i, j; + for(j = 0; n > 0; j++) { + for(i = 1; ; i++) + if(pow(2, i) > n) break; + // m stores the largest number. + m[j] = --i; + n -= pow(2, i); + } + + for(i = 0; i < j; i++) + res += pow(k, m[i]); + + #ifdef _CPP_ + cout<