intmain() { int N; cin >> N; int cnt[100010]; memset( cnt , 0 , 100010 * 4); for ( int i = 0 ; i < N ; i ++) { int t; scanf("%d",&t); cnt[t] ++; cnt[t + 1] ++; cnt[t - 1] ++; } int res = 0; for ( int i = 0 ; i < 100010 ; i ++) { if ( cnt[i] > res ) res = cnt[i]; } printf("%d",res);
intmain() { int k; while ( scanf("%d",&k) != EOF) { int cnt = 0 , a[10000] , b[10000]; for ( int x = k + 1 ; x <= 2 * k ; x ++) { if ( ( k * x ) % ( x - k ) == 0 ) { a[cnt] = x; b[cnt] = ( k * x) / ( x - k); cnt ++; } } printf("%d\n",cnt); for ( int i = 0 ; i < cnt ; i ++) { printf("1/%d = 1/%d + 1/%d\n", k , b[i] , a[i]); } } return0; }
intmain() { int N ,num = 0; while ( scanf("%d",&N) != EOF) { num ++; int a[N+10] ; for ( int i = 0 ; i < N ; i ++) { scanf("%d",&a[i]); } longlong res = 0; for ( int i = 0 ; i < N ; i ++) { longlong ans = 1; for ( int j = i ; j < N ; j ++) { ans *= a[j]; if ( ans > res ) res = ans; } } printf("Case #%d: The maximum product is %lld.\n\n", num, res); } return0; }
Problem D - Division
题目描述:
翻译成人话:
给定一个数N,满足abcde / fghij = N,并且a b c d e f g h i j这十个数不能重复
boolis_appear_once( int x , int y) { if ( x > 99999 || y > 99999) returnfalse; int cnt[10]; memset( cnt , 0 , 10 * 4); for ( int i = 0 ; i < 5 ; i ++) { cnt[x % 10] ++; x /= 10; } for ( int i = 0 ; i < 5 ; i ++) { cnt[y % 10] ++; y /= 10; } for ( int i = 0 ; i < 10 ; i ++) { if ( cnt[i] != 1) returnfalse; } returntrue; }
intmain() { int n; bool is_first = true; while ( scanf("%d",&n) != EOF && n ) { if( !is_first ) printf("\n"); is_first = false; bool is_find = false; for ( int i = 1234 ; i < 100000 ; i ++) { if ( is_appear_once( i , i * n)) { printf("%05d / %05d = %d\n", i * n , i , n); is_find = true; } } if ( !is_find) printf("There are no solutions for %d.\n", n );
intmain() { int N; cin >> N; while ( N --) { int len , num; cin >> len >> num; int a[1000010]; for ( int i = 0 ; i < num ; i ++) cin >> a[i]; int mins = 0 , maxs = 0; for ( int i = 0 ; i < num ; i ++) { mins = max( min(a[i] , len - a[i] ), mins); } for ( int i = 0 ; i < num ; i ++) { maxs = max( max(a[i] , len - a[i] ), maxs); } cout << mins << " " << maxs << endl; }