ACM n n n acm nefu edu cn
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-1.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-2.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-3.jpg)
![我校的ACM在线评测系统 n n n acm. nefu. edu. cn 课件下载地址: acm. nefu. edu. cn/kj/acm 03. 我校的ACM在线评测系统 n n n acm. nefu. edu. cn 课件下载地址: acm. nefu. edu. cn/kj/acm 03.](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-4.jpg)
![还看N!的位数这题 n n n Hdu 1018 Big Number Pku 1423 Big Number 用 1+lg(1)+lg(2)+. 还看N!的位数这题 n n n Hdu 1018 Big Number Pku 1423 Big Number 用 1+lg(1)+lg(2)+.](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-5.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-6.jpg)
![n n n n 假设问题给出的C组数据,是从小往大排列的,例如, 给出三个数据,10,20,30,那么我们可以想到, 计算log 10(20!)的时候,我们是可以利用long 10(10!) 的结果。因为: log 10(10!) = log n n n n 假设问题给出的C组数据,是从小往大排列的,例如, 给出三个数据,10,20,30,那么我们可以想到, 计算log 10(20!)的时候,我们是可以利用long 10(10!) 的结果。因为: log 10(10!) = log](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-7.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-8.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-9.jpg)
![n n n n n #include <iostream> #include <math. h> using namespace std; //注意 n n n n n #include <iostream> #include <math. h> using namespace std; //注意](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-10.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-11.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-12.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-13.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-14.jpg)
![n n n n long a, b, c, sum; while(cin>>a>>b) { if (a==0&&b==0) break; n n n n long a, b, c, sum; while(cin>>a>>b) { if (a==0&&b==0) break;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-15.jpg)
![计算N! n n n 72题 输入不超过10000的正整数n, 计算n!的具体值? 输入: 30 输出: 265252859812191058636308480000000 2021/3/11 16 计算N! n n n 72题 输入不超过10000的正整数n, 计算n!的具体值? 输入: 30 输出: 265252859812191058636308480000000 2021/3/11 16](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-16.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-17.jpg)
![先定义变量 n n const int maxn=50000; int n, c, k; int f[maxn+1]; 如果不知道 10000!的阶乘有多少位,那肯定 先定义变量 n n const int maxn=50000; int n, c, k; int f[maxn+1]; 如果不知道 10000!的阶乘有多少位,那肯定](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-18.jpg)
![n n while(cin>>n) { n memset(f, 0, sizeof(f)); f[0]=1; for (int i=1; i<=n; i++) n n while(cin>>n) { n memset(f, 0, sizeof(f)); f[0]=1; for (int i=1; i<=n; i++)](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-19.jpg)
![看输出部分 n n n for(k=maxn; k>=0; k--) if (f[k]!=0) break; for(int j=k; j>=0; j--) 看输出部分 n n n for(k=maxn; k>=0; k--) if (f[k]!=0) break; for(int j=k; j>=0; j--)](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-20.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-21.jpg)
![如何打印输出? n n n n 12!=479001600,后5位01600,输出是 1600 ,要处理好这个问题就行了! for(k=maxn; k>=0; k--) if (f[k]!=0) break; 如何打印输出? n n n n 12!=479001600,后5位01600,输出是 1600 ,要处理好这个问题就行了! for(k=maxn; k>=0; k--) if (f[k]!=0) break;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-22.jpg)
![还 能不能更快,一定能!先计算N!的 for(int i=1; i<=n; i++) 位数 { n n n int a[40000]; int 还 能不能更快,一定能!先计算N!的 for(int i=1; i<=n; i++) 位数 { n n n int a[40000]; int](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-23.jpg)
![时间 690 MS n n n n for(k=wei; k>=0; k--) if(a[k]!=0) break; printf("%d", a[k]); 时间 690 MS n n n n for(k=wei; k>=0; k--) if(a[k]!=0) break; printf("%d", a[k]);](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-24.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-25.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-26.jpg)
![#include <stdio. h> #include <string. h> int main( ) { char add 1[11], add #include <stdio. h> #include <string. h> int main( ) { char add 1[11], add](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-27.jpg)
![while( i 1>=0 ) //如果第 1个加数还有若干位没有运算完 { if( add 1[i 1]-'0'+C>9 ) { carry++; while( i 1>=0 ) //如果第 1个加数还有若干位没有运算完 { if( add 1[i 1]-'0'+C>9 ) { carry++;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-28.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-29.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-30.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-31.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-32.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-33.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-34.jpg)
![#include <stdio. h> #include <string. h> #include <math. h> int main( ) { char #include <stdio. h> #include <string. h> #include <math. h> int main( ) { char](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-35.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-36.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-37.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-38.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-39.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-40.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-41.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-42.jpg)
![for( k=1; k<=N; k++ ) { maxlen = -1; memset( array, 0, sizeof(array) ); for( k=1; k<=N; k++ ) { maxlen = -1; memset( array, 0, sizeof(array) );](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-43.jpg)
![carry = 0; for( i = 0; i < maxlen+2; i++ ) //对这些整数的每位进行求和 { carry = 0; for( i = 0; i < maxlen+2; i++ ) //对这些整数的每位进行求和 {](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-44.jpg)
![How Many Fibs? Hdu 1316 Recall the definition of the Fibonacci numbers: f 1 How Many Fibs? Hdu 1316 Recall the definition of the Fibonacci numbers: f 1](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-45.jpg)
![Output For each test case output on a single line the number of Fibonacci Output For each test case output on a single line the number of Fibonacci](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-46.jpg)
![代码 2分+高精度 n n n n #include <iostream> #include <cstdlib> #include <cstring> #define M 代码 2分+高精度 n n n n #include <iostream> #include <cstdlib> #include <cstring> #define M](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-47.jpg)
![n n n n n n n int find 1(int i, char *x) { n n n n n n n int find 1(int i, char *x) {](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-48.jpg)
![n n n int main() { int i, j, p; //memset(data, 0, sizeof(data)); data[0][105]=1; n n n int main() { int i, j, p; //memset(data, 0, sizeof(data)); data[0][105]=1;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-49.jpg)
![n n n n n n while(cin>>a>>b) { if (a[0]=='0'&&b[0]=='0') break; int len 1=strlen(a)-1; n n n n n n while(cin>>a>>b) { if (a[0]=='0'&&b[0]=='0') break; int len 1=strlen(a)-1;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-50.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-51.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-52.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-53.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-54.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-55.jpg)
![#include <stdio. h> #include <string. h> char a[101], b[101]; //输入的两个正整数(字符形式) int len_a, len_b; //输入的正整数长度 #include <stdio. h> #include <string. h> char a[101], b[101]; //输入的两个正整数(字符形式) int len_a, len_b; //输入的正整数长度](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-56.jpg)
![for( i=0; i<len_b; i++ ) //用大整数b的每位去乘大整数a { int start = i; //得到的中间结果跟大整数b中的位对齐 for( j=0; for( i=0; i<len_b; i++ ) //用大整数b的每位去乘大整数a { int start = i; //得到的中间结果跟大整数b中的位对齐 for( j=0;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-57.jpg)
![Welcome to HDOJ Thank You ~ 2021/3/11 58 Welcome to HDOJ Thank You ~ 2021/3/11 58](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-58.jpg)
- Slides: 58
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-1.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-2.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-3.jpg)
![我校的ACM在线评测系统 n n n acm nefu edu cn 课件下载地址 acm nefu edu cnkjacm 03 我校的ACM在线评测系统 n n n acm. nefu. edu. cn 课件下载地址: acm. nefu. edu. cn/kj/acm 03.](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-4.jpg)
我校的ACM在线评测系统 n n n acm. nefu. edu. cn 课件下载地址: acm. nefu. edu. cn/kj/acm 03. ppt 2021/3/11 4
![还看N的位数这题 n n n Hdu 1018 Big Number Pku 1423 Big Number 用 1lg1lg2 还看N!的位数这题 n n n Hdu 1018 Big Number Pku 1423 Big Number 用 1+lg(1)+lg(2)+.](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-5.jpg)
还看N!的位数这题 n n n Hdu 1018 Big Number Pku 1423 Big Number 用 1+lg(1)+lg(2)+. . +lg(n)的方法,在PKU上 TLE 了,超时了 2021/3/11 5
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-6.jpg)
![n n n n 假设问题给出的C组数据是从小往大排列的例如 给出三个数据102030那么我们可以想到 计算log 1020的时候我们是可以利用long 1010 的结果因为 log 1010 log n n n n 假设问题给出的C组数据,是从小往大排列的,例如, 给出三个数据,10,20,30,那么我们可以想到, 计算log 10(20!)的时候,我们是可以利用long 10(10!) 的结果。因为: log 10(10!) = log](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-7.jpg)
n n n n 假设问题给出的C组数据,是从小往大排列的,例如, 给出三个数据,10,20,30,那么我们可以想到, 计算log 10(20!)的时候,我们是可以利用long 10(10!) 的结果。因为: log 10(10!) = log 10(1) + log 10(2) + log 10(3) +. . . + log 10(9) +log 10(10) log 10(20!) = log 10(1) + log 10(2) + log 10(3) +. . . + log 10(9) +log 10(10) + log 10(11) + log 10(12) +. . . +log 10(19) + log 10(20) 容易看出: log 10(20!) = log 10(10!) + log 10(11) + log 10(12) +. . . +log 10(19) + log 10(20) ; 同理: log 10(30!) = log 10(10!) + log 10(21) + log 10(22) +. . . +log 10(29) + log 10(30) ; 2021/3/11 7
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-8.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-9.jpg)
![n n n n n include iostream include math h using namespace std 注意 n n n n n #include <iostream> #include <math. h> using namespace std; //注意](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-10.jpg)
n n n n n #include <iostream> #include <math. h> using namespace std; //注意 e和pi的值要精确 const double 2. 718284590452354, pi = 3. 141592653589793239; double str_ling(int n) { return 0. 5*log 10(2*pi*n)+n*log 10(n/e); } int main() { int t, m; cin>>t; while(t--) { cin>> m; cout<<(int)str_ling(m)+1<<endl; } system("pause"); return 1; } 2021/3/11 10
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-11.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-12.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-13.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-14.jpg)
![n n n n long a b c sum whilecinab if a0b0 break n n n n long a, b, c, sum; while(cin>>a>>b) { if (a==0&&b==0) break;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-15.jpg)
n n n n long a, b, c, sum; while(cin>>a>>b) { if (a==0&&b==0) break; c=0; sum=0; for(int i=0; i<=9; i++) { if ((a%10+b%10+c)>=10) {sum++; c=1; } else c=0; a=a/10; b=b/10; n n 2021/3/11 } 15
![计算N n n n 72题 输入不超过10000的正整数n 计算n的具体值 输入 30 输出 265252859812191058636308480000000 2021311 16 计算N! n n n 72题 输入不超过10000的正整数n, 计算n!的具体值? 输入: 30 输出: 265252859812191058636308480000000 2021/3/11 16](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-16.jpg)
计算N! n n n 72题 输入不超过10000的正整数n, 计算n!的具体值? 输入: 30 输出: 265252859812191058636308480000000 2021/3/11 16
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-17.jpg)
![先定义变量 n n const int maxn50000 int n c k int fmaxn1 如果不知道 10000的阶乘有多少位那肯定 先定义变量 n n const int maxn=50000; int n, c, k; int f[maxn+1]; 如果不知道 10000!的阶乘有多少位,那肯定](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-18.jpg)
先定义变量 n n const int maxn=50000; int n, c, k; int f[maxn+1]; 如果不知道 10000!的阶乘有多少位,那肯定 WA! 2021/3/11 18
![n n whilecinn n memsetf 0 sizeoff f01 for int i1 in i n n while(cin>>n) { n memset(f, 0, sizeof(f)); f[0]=1; for (int i=1; i<=n; i++)](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-19.jpg)
n n while(cin>>n) { n memset(f, 0, sizeof(f)); f[0]=1; for (int i=1; i<=n; i++) { c=0; //代表进位 for(int j=0; j<=maxn; j++) { int s=f[j]*i+c; f[j]=s%10; c=s/10; } n n n } 2021/3/11 19
![看输出部分 n n n forkmaxn k0 k if fk0 break forint jk j0 j 看输出部分 n n n for(k=maxn; k>=0; k--) if (f[k]!=0) break; for(int j=k; j>=0; j--)](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-20.jpg)
看输出部分 n n n for(k=maxn; k>=0; k--) if (f[k]!=0) break; for(int j=k; j>=0; j--) cout<<f[j]; cout<<endl; } 2021/3/11 20
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-21.jpg)
![如何打印输出 n n n n 12479001600后5位01600输出是 1600 要处理好这个问题就行了 forkmaxn k0 k if fk0 break 如何打印输出? n n n n 12!=479001600,后5位01600,输出是 1600 ,要处理好这个问题就行了! for(k=maxn; k>=0; k--) if (f[k]!=0) break;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-22.jpg)
如何打印输出? n n n n 12!=479001600,后5位01600,输出是 1600 ,要处理好这个问题就行了! for(k=maxn; k>=0; k--) if (f[k]!=0) break; printf("%d", f[k]); for(int j=k-1; j>=0; j--) printf(“%05 d”, f[j]); //5位的数字,不足前面 添 0 printf("n"); 2021/3/11 22
![还 能不能更快一定能先计算N的 forint i1 in i 位数 n n n int a40000 int 还 能不能更快,一定能!先计算N!的 for(int i=1; i<=n; i++) 位数 { n n n int a[40000]; int](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-23.jpg)
还 能不能更快,一定能!先计算N!的 for(int i=1; i<=n; i++) 位数 { n n n int a[40000]; int main() { int n, k, l; double wei; while(cin>>n) { memset(a, 0, sizeof(a)); a[0]=1; wei=0; int c=0; wei+=log 10(i); k=((int)wei+1)/5; for(int j=0; j<=k; j++) { int s=a[j]*i+c; a[j]=s%100000; c=s/100000; } }
![时间 690 MS n n n n forkwei k0 k ifak0 break printfd ak 时间 690 MS n n n n for(k=wei; k>=0; k--) if(a[k]!=0) break; printf("%d", a[k]);](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-24.jpg)
时间 690 MS n n n n for(k=wei; k>=0; k--) if(a[k]!=0) break; printf("%d", a[k]); k--; for(k; k>=0; k--) printf("%05 d", a[k]); printf("n"); }
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-25.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-26.jpg)
![include stdio h include string h int main char add 111 add #include <stdio. h> #include <string. h> int main( ) { char add 1[11], add](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-27.jpg)
#include <stdio. h> #include <string. h> int main( ) { char add 1[11], add 2[11]; //读入的两个加数 while( scanf("%s%s", add 1, add 2) ) { if( !strcmp(add 1, "0") && !strcmp(add 2, "0") ) break; int carry = 0; //进位次数 int i 1 = strlen(add 1) - 1; int i 2 = strlen(add 2) - 1; int C = 0; //进位 while( i 1>=0 && i 2>=0 ) //从两加数右边开始对每位相加 { if( add 1[i 1]-'0'+add 2[i 2]-'0'+C>9 ) { carry++; C = 1; } else C = 0; i 1 --; i 2 --; } 2021/3/11 27
![while i 10 如果第 1个加数还有若干位没有运算完 if add 1i 10C9 carry while( i 1>=0 ) //如果第 1个加数还有若干位没有运算完 { if( add 1[i 1]-'0'+C>9 ) { carry++;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-28.jpg)
while( i 1>=0 ) //如果第 1个加数还有若干位没有运算完 { if( add 1[i 1]-'0'+C>9 ) { carry++; C = 1; } else C = 0; i 1 --; } while( i 2>=0 ) //如果第 1个加数还有若干位没有运算完 { if( add 2[i 2]-'0'+C>9 ) { carry++; C = 1; } else C = 0; i 2 --; } if( carry>1 ) printf( "%d carry operations. n", carry ); else if( carry==1 ) printf( "%d carry operation. n", carry ); else printf( "No carry operation. n" ); } } return 0; 2021/3/11 28
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-29.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-30.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-31.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-32.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-33.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-34.jpg)
![include stdio h include string h include math h int main char #include <stdio. h> #include <string. h> #include <math. h> int main( ) { char](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-35.jpg)
#include <stdio. h> #include <string. h> #include <math. h> int main( ) { char str[40]; //读入的每个skew二进制数,用字符数组存放 while( scanf( "%s", str )!=EOF ) { int len = strlen(str); //高精度数的总位数就是字符串的长度 int num = 0; //对应的十进制数 if( len==1 && str[0]==‘ 0’ ) break; //输入 0,就退出 for( int i=len-1; i>=0; i-- ) //高精度数的每位:str[i]-'0' num += (str[i]-‘ 0’)*( pow(2, len-i) - 1 ); //注意 printf( "%dn", num ); } return 0; } 2021/3/11 35
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-36.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-37.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-38.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-39.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-40.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-41.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-42.jpg)
![for k1 kN k maxlen 1 memset array 0 sizeofarray for( k=1; k<=N; k++ ) { maxlen = -1; memset( array, 0, sizeof(array) );](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-43.jpg)
for( k=1; k<=N; k++ ) { maxlen = -1; memset( array, 0, sizeof(array) ); memset( answer, 0, sizeof(answer) ); for( num_integers = 0; num_integers < 200; num_integers++ ) { gets( buffer ); if( strcmp(buffer, "0") == 0 ) break; len = strlen(buffer); if( len>maxlen ) maxlen = len; for( i = 0; i < len; i++ )//逆序存放大数的每位(整数形式) array[num_integers][i] = buffer[len - 1 - i] - '0'; } 2021/3/11 43
![carry 0 for i 0 i maxlen2 i 对这些整数的每位进行求和 carry = 0; for( i = 0; i < maxlen+2; i++ ) //对这些整数的每位进行求和 {](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-44.jpg)
carry = 0; for( i = 0; i < maxlen+2; i++ ) //对这些整数的每位进行求和 { sum = carry; for( j = 0; j < num_integers; j++ ) sum += array[j][i]; digit = sum % 10; carry = sum / 10; answer[i] = digit; } for( i = maxlen+2; i >= 0; i-- ) //统计求和结果的位数 { if( answer[i] != 0 ) break; } while( i >= 0 ) printf( "%d", answer[i--] ); //逆序输出求和结果 printf( "n" ); if( k<N ) printf( "n" ); //两个输出块之间有一个空行 } } return 0; 2021/3/11 44
![How Many Fibs Hdu 1316 Recall the definition of the Fibonacci numbers f 1 How Many Fibs? Hdu 1316 Recall the definition of the Fibonacci numbers: f 1](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-45.jpg)
How Many Fibs? Hdu 1316 Recall the definition of the Fibonacci numbers: f 1 : = 1 f 2 : = 2 fn : = fn-1 + fn-2 (n >= 3) Given two numbers a and b, calculate how many Fibonacci numbers are in the range [a, b]. Input The input contains several test cases. Each test case consists of two non-negative integer numbers a and b. Input is terminated by a = b = 0. Otherwise, a <= b <= 10^100. The numbers a and b are given with no superfluous leading zeros. 2021/3/11 45
![Output For each test case output on a single line the number of Fibonacci Output For each test case output on a single line the number of Fibonacci](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-46.jpg)
Output For each test case output on a single line the number of Fibonacci numbers fi with a <= fi <= b. Sample Input 10 100 1234567890 9876543210 0 0 Sample Output 5 4 2021/3/11 46
![代码 2分高精度 n n n n include iostream include cstdlib include cstring define M 代码 2分+高精度 n n n n #include <iostream> #include <cstdlib> #include <cstring> #define M](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-47.jpg)
代码 2分+高精度 n n n n #include <iostream> #include <cstdlib> #include <cstring> #define M 105 using namespace std; char data[1000][M+2]; char a[M+2], b[M+2]; int cmp_ab(char *s 1, char *s 2) { for(int k=0; k<=105; k++) { if (k==105) return s 1[k]-s 2[k]; if (s 1[k]!=s 2[k]) return s 1[k]-s 2[k]; } n n }
![n n n n n n n int find 1int i char x n n n n n n n int find 1(int i, char *x) {](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-48.jpg)
n n n n n n n int find 1(int i, char *x) { int low=0, high=i, mid; while(low<=high) { mid=(low+high)/2; int value=cmp_ab(x, data[mid]); if (value>0) low=mid+1; if (value==0) return mid-1; if (value<0) high=mid-1; } return high; //这时候high小于low } int find 2(int i, char *x) { int low=0, high=i, mid; while(low<=high) { mid=(low+high)/2; int value=cmp_ab(x, data[mid]); if (value>0) low=mid+1; if (value==0) return mid+1; if (value<0) high=mid-1; } return low; //这时候 low大于high }
![n n n int main int i j p memsetdata 0 sizeofdata data01051 n n n int main() { int i, j, p; //memset(data, 0, sizeof(data)); data[0][105]=1;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-49.jpg)
n n n int main() { int i, j, p; //memset(data, 0, sizeof(data)); data[0][105]=1; data[1][105]=2; i=2; p=105; while(data[i-1][5]<=1) { for(j=105; j>=p; j--) data[i][j]=data[i-1][j]+data[i-2][j]; for(j=105; j>=p; j--) { int c=data[i][j]/10; if (c>=1) { data[i][j]=data[i][j]%10; data[i][j-1]=data[i][j-1]+c; } n n n n } if (data[i][p-1]>0) p--; i++; n n }
![n n n n n n whilecinab if a00b00 break int len 1strlena1 n n n n n n while(cin>>a>>b) { if (a[0]=='0'&&b[0]=='0') break; int len 1=strlen(a)-1;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-50.jpg)
n n n n n n while(cin>>a>>b) { if (a[0]=='0'&&b[0]=='0') break; int len 1=strlen(a)-1; int len 2=strlen(b)-1; int k; for(int d=len 1, k=105; d>=0; d--, k--) { a[k]=a[d]-'0'; a[d]=0; } for(int d=len 2, k=105; d>=0; d--, k--) { b[k]=b[d]-'0'; b[d]=0; } /*for(int i=0; i<=105; i++) cout<<(int)b[i]; cout<<endl; */ int lt=find 1(i-1, a); int rt=find 2(i-1, b); n cout<<rt-lt-1<<endl; memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); n n } return 0; n n }
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-51.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-52.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-53.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-54.jpg)
![](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-55.jpg)
![include stdio h include string h char a101 b101 输入的两个正整数字符形式 int lena lenb 输入的正整数长度 #include <stdio. h> #include <string. h> char a[101], b[101]; //输入的两个正整数(字符形式) int len_a, len_b; //输入的正整数长度](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-56.jpg)
#include <stdio. h> #include <string. h> char a[101], b[101]; //输入的两个正整数(字符形式) int len_a, len_b; //输入的正整数长度 int ai[101], bi[101]; //输入的两个正整数(以整数形式存储每一位) int temp[202]; //每一位乘法的中间结果 char product[201]; //乘积 void reverse( char s[ ], int si[] ) //以逆序顺序存放大数中的各位数(整数形式) { int len = strlen(s); for( int i=0; i<len; i++ ) si[len-1 -i] = s[i]-'0'; } int main( ) { int i, j; while( scanf( "%s", a ) != EOF ) { scanf( "%s", b ); len_a = strlen(a); len_b = strlen(b); reverse(a, ai); reverse(b, bi); memset( temp, 0, sizeof(temp) ); 2021/3/11 56 memset( product, 0, sizeof(product) );
![for i0 ilenb i 用大整数b的每位去乘大整数a int start i 得到的中间结果跟大整数b中的位对齐 for j0 for( i=0; i<len_b; i++ ) //用大整数b的每位去乘大整数a { int start = i; //得到的中间结果跟大整数b中的位对齐 for( j=0;](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-57.jpg)
for( i=0; i<len_b; i++ ) //用大整数b的每位去乘大整数a { int start = i; //得到的中间结果跟大整数b中的位对齐 for( j=0; j<len_a; j++ ) { temp[start++] += ai[j]*bi[i]; } } for( i=0; i<202; i++ ) //低位向高位进位 { if( temp[i]>9 ) { temp[i+1] += temp[i]/10; temp[i] = temp[i]%10; } } for( i=201; i>=0; i-- ) //求乘积的长度 { if( temp[i] ) break; } int lenp = i+1; //乘积的长度 for( i=0; i<lenp; i++ ) //将乘积各位转换成字符形式 product[lenp-1 -i] = temp[i]+'0'; product[lenp] = 0; //串结束符标志 printf( "%sn", product ); } } return 0; 2021/3/11 57
![Welcome to HDOJ Thank You 2021311 58 Welcome to HDOJ Thank You ~ 2021/3/11 58](https://slidetodoc.com/presentation_image_h/35a8ec3fdccb736c0883d065d8f4c941/image-58.jpg)
Welcome to HDOJ Thank You ~ 2021/3/11 58
Edu.sharif.edu
Acm
Acm symposium on cloud computing
Icpc neerc
Acm
Acm/ieee etik kuralları
Acm certification practice test
Acm awards
Springer elsevier
Acm icpc
Acm
8 general moral imperatives
Acm/ieee etik kuralları
Asbestos removal edithvale
Acm code of ethics summary
Scott delman acm
Acm ethics corporate
øhs
Quy tắc ứng xử acm
Acm
Acm sigs sigsac
Ventrikel ct scan
Grouper active directory
Acm ethics corporate
Acm international academy
Adaptive case management definition
Holoparazité
Www.meted.com
Tcl massage
Greenfoot breakout
Digitalstorytelling coe uh edu
Telnet cis.poly.edu 80
Library uts
Sabis esınav
Sigla edu
Global edge.msu.edu
Pprr cycle
Mis.edu.nt
Toros üni lms
Www.uii
Biology.arizona.edu/cell bio/activities/cell cycle/01.html
Chapter 17 darwins theory of evolution
Antonio sandoval ucla
Ksu.edu.tw
Nccommunitycolleges.edu
Breakout edu
Transverse wave ex
Brenau intranet
Akun acs upi
Wu wsiz rzeszow
Rsd edu
Dig comp edu
Www.edu.slaskie/kandydat ponadpodstawowych
Www kean edu
Ai2.appinventor.mit.edu emulator
Campus web brenau
Internet classics
Getty.edu
Gümüşhane dbs giriş