01
02
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <iomanip> #include <cstring> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> using namespace std; int bb[8] = {0}; void Function(int n) { if(n < 0) n = 256 + n; memset(bb,0,sizeof(bb)); int i = 0; while(n) { bb[i++] = n % 2; n = n / 2; } for(int k = 7;k >= 0;k--) if(bb[k]) cout<<"*"<<" "; else cout<<" "<<" "; } int main() { int array[2] = {0}; fstream inFile("E:\字库.txt",ios::in); for(int i = 0;i < 10;++i) { memset(array,0,sizeof(array)); for(int j = 0;j < 16;j++) { inFile>>array[0]>>array[1]; Function(array[0]); Function(array[1]); cout<<endl; } cout<<endl<<"---------------------------------------------------"<<" i = "<<i<<endl; } inFile.close(); return 0; }
03
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <iomanip> #include <cstring> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> using namespace std; int Function(int & n) { int ans = 0; while(1) { if(n % 10 == 0) ans++; else break; n /= 10; } return ans; } int main() { int ans = 0, sum = 1; int array[10]; fstream Infile("E:\文本文档.txt",ios::in); for(int i = 0;i < 10;i++) { for(int j = 0;j < 10;j++) { Infile>>array[j]; sum *= array[j]; ans += Function(sum); if(sum > 100000) sum = sum % 1000; } } cout<<ans<<endl; Infile.close(); return 0; }
04
表示不会!
05
quick_select(a,i,r,k - i - 1 + l);
06 肯定不会超时
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <iomanip> #include <cstring> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> using namespace std; void Function( ) { } int main() { int n; cin>>n; int * A = new int [n],* B = new int [n],* C = new int [n]; int * b = new int [n],* c = new int [n]; for(int i = 0;i < n;i++) scanf("%d",&A[i]); for(int i = 0;i < n;i++) scanf("%d",&B[i]); for(int i = 0;i < n;i++) scanf("%d",&C[i]); sort(A,A+n); sort(B,B+n); sort(C,C+n); int ans = 0,bzong = 0; //总数 int ib = 0,ic = 0; // b ,c 下标 int ansb = 0, ansc = 0; // 个数 for(int i = 0;i < n || ib < n;) { if(i == n) { b[ib++] = ansb; continue; } if(A[i] < B[ib] && i < n) { ansb++; i++; // cout<<i<<"-------"<<ansb<<endl; } else { b[ib++] = ansb; } } for(int i = 0;i < n || ic < n;) { if(i == n) { c[ic++] = ansc; ans += bzong; continue; } if(B[i] < C[ic] && i < n) { bzong += b[i]; ansc++; i++; } else { c[ic] = ansc; ans += bzong; // cout<<ic<<"-------"<<ans<<endl; ic++; } } cout<<ans<<endl; // cout<<"bzong : "<<bzong<<endl; // for(int i = 0;i < n;i++) // printf("%d ",c[i]); delete[] A; delete[] B; delete[] C; delete[] b; delete[] c; return 0; }
07
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <iomanip> #include <cstring> #include <vector> #include <list> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> using namespace std; void digui_1(int n) { } int main() { long long x,y,t,ans = 0; cin>>x>>y; if(x >= 0 && y >= 0) { t = max(x,y); ans = 4 * t * t + x - y; } else if(x < 0 && y >= 0) { t = max(-x,y); ans = 2 * t * (2 * t - 1) + x + y; } else if(x >= 0 && y < 0) { t = max(x,-y); ans = 2 * t * (2 * t + 1) - x - y; } else { if(x < y) t = - x - x - 1; else t = - y - y + 1; ans = t * t - x + y - 1; } cout<<ans<<endl; return 0; }
08