Microsoft Windows XP [版本 5.1.2600] (C) 版权所有 1985-2001 Microsoft Corp. C:Documents and SettingsAdministrator>e: E:>dir 驱动器 E 中的卷没有标签。 卷的序列号是 000A-A2B1 E: 的目录 2017-01-16 09:30 <DIR> ADSafe 2017-01-16 09:31 <DIR> OIPackages 2017-01-16 09:31 <DIR> QQ 2017-01-16 05:40 <DIR> sougou 0 个文件 0 字节 4 个目录 53,112,700,928 可用字节 E:>cd OIPackages E:OIPackages>cd Dev-Cpp E:OIPackagesDev-Cpp>cd MinGW32 E:OIPackagesDev-CppMinGW32>cd bin E:OIPackagesDev-CppMinGW32in>g++ -g e:a.cpp -o a g++: e:a.cpp: No such file or directory g++: no input files E:OIPackagesDev-CppMinGW32in>g++ -g f:a.cpp -o a E:OIPackagesDev-CppMinGW32in>gdb a GNU gdb 6.8 Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-mingw32"... (gdb) l 18 return pos==a.pos?r<a.r:pos<a.pos; 19 } 20 }b[N]; 21 int n,m,l,r,a[N],f[N]; 22 ll res,ans1[N],ans2[N]; 23 ll gcd(ll a,ll b){ 24 if(!b) return a; 25 return gcd(b,a%b); 26 } 27 int main(){ (gdb) 28 //freopen("hose.in","r",stdin); 29 //freopen("hose.out","w",stdout); 30 n=read();m=read(); 31 for(int i=1;i<=n;i++) a[i]=read(); 32 int k=sqrt(n*1.0)+0.5; 33 for(int i=1;i<=m;i++){ 34 b[i].l=read();b[i].r=read(); 35 b[i].t=i;b[i].pos=b[i].l/k; 36 } 37 sort(b+1,b+m+1); (gdb) 38 memset(f,0,sizeof f); 39 l=1;r=0;res=0; 40 for(int i=1;i<=m;i++){ 41 while(r>b[i].r){ 42 res-=(ll)f[a[r]]-1; 43 f[a[r]]--; 44 r--; 45 } 46 while(r<b[i].r){ 47 r++; (gdb) 48 f[a[r]]++; 49 res+=(ll)f[a[r]]-1; 50 } 51 while(l>b[i].l){ 52 l--; 53 f[a[l]]++; 54 res+=(ll)f[a[l]]-1; 55 } 56 while(l<b[i].l){ 57 res-=(ll)f[a[l]]-1; (gdb) 58 f[a[l]]--; 59 l++; 60 } 61 ans1[b[i].t]=res; 62 ans2[b[i].t]=(ll)(r-l+1)*(r-l)/2; 63 } 64 for(int i=1;i<=m;i++){ 65 if(!ans1[i]){ 66 puts("0/1"); 67 continue; (gdb) 68 } 69 ll gg=gcd(ans1[i],ans2[i]); 70 printf("%lld/%lld ",ans1[i]/gg,ans2[i]/gg); 71 //printf("%I64d/%I64d ",ans1[i]/gg,ans2[i]/gg); 72 } 73 return 0; 74 }(gdb) Line number 75 out of range; f:a.cpp has 74 lines. (gdb) Line number 75 out of range; f:a.cpp has 74 lines. (gdb) b 50 Breakpoint 1 at 0x40178a: file f:a.cpp, line 50. (gdb) b if i=50 No default breakpoint address now. (gdb) n The program is not being run. (gdb) s The program is not being run. (gdb) continue The program is not being run. (gdb) p i No symbol "i" in current context. (gdb) p n $1 = 0 (gdb) p *a@N $2 = {0 <repeats 200007 times>} (gdb) display i No symbol "i" in current context. (gdb) i b Num Type Disp Enb Address What 1 breakpoint keep y 0x0040178a in main at f:a.cpp:50 (gdb) set i=100 Ambiguous set command "i=100": . (gdb) p gcd(5,6) You can't do that without a process to debug. (gdb)
未完待续