标签:pen stdin sizeof section i++ while open count ast
1 /* 2 ID:xiekeyi1 3 PROG:milk 4 LANG:C++ 5 */ 6 7 #include<bits/stdc++.h> 8 using namespace std ; 9 10 const int maxm = 5050 ; 11 12 struct P 13 { 14 int price ; 15 int amount ; 16 }a[maxm]; 17 18 bool cmp( struct P a , struct P b ) 19 { 20 return ( a.price < b.price ) ; 21 } 22 23 24 int main() 25 { 26 freopen("milk.in","r",stdin); 27 freopen("milk.out","w",stdout); 28 ios::sync_with_stdio(false); 29 cin.tie(false) ; 30 int n ; 31 int m ; 32 cin >> n >> m ; 33 for( int i = 1 ; i <= m ; i++) 34 cin >> a[i].price >> a[i].amount ; 35 sort(a+1,a+1+m,cmp); 36 int ans = 0 ; 37 int cnt = 1 ; 38 while( n != 0 ) 39 { 40 if( a[cnt].amount <= n ) 41 { 42 n -= a[cnt].amount; 43 ans += a[cnt].amount * a[cnt].price; 44 a[cnt].amount = 0 ; 45 } 46 else 47 { 48 ans+= n * a[cnt].price ; 49 a[cnt].amount -= n ; 50 n = 0 ; 51 } 52 cnt++; 53 } 54 55 cout << ans << endl ; 56 return 0 ; 57 }
1 /* 2 ID:xiekeyi1 3 PROG:barn1 4 LANG:C++ 5 */ 6 7 #include<bits/stdc++.h> 8 using namespace std ; 9 int a[210]; 10 int maxr = 0 ; 11 int minl = 999 ; 12 void filling( int l , int r ) 13 { 14 for( int i = l ; i <= r ; i++ ) 15 a[i] = 3 ; 16 } 17 18 19 int func() 20 { 21 int l = 0 , r = 0 ; 22 int cnt = 0 ; 23 for( int i = minl ; i <= maxr ; i++) 24 { 25 if( a[i] != 0 ) 26 continue ; 27 int temp = 1 ; 28 int j ; 29 for( j = i + 1 ; j <= maxr ; j++) 30 { 31 if( a[j] == 0 ) 32 temp++; 33 else 34 break ; 35 } 36 37 if( temp >= ( r - l + 1 ) ) 38 l = i , r = j - 1 , cnt = temp ; ; 39 } 40 41 filling( l , r ) ; 42 return cnt ; 43 } 44 45 46 int main() 47 { 48 49 freopen("barn1.in","r",stdin); 50 freopen("barn1.out","w",stdout); 51 int m , s , c ; 52 cin >> m >> s >> c ; 53 memset( a , 0 , sizeof(a) ) ; 54 int ans = 0 , mm = 1 ; 55 for( int i = 1 ; i <= c ; i++) 56 { 57 int t ; 58 cin >> t ; 59 a[t] = 1 ; 60 maxr = max( t , maxr ) ; 61 minl = min( minl , t ) ; 62 } 63 ans = maxr - minl + 1 ; 64 65 while( mm < m && mm < c ) 66 { 67 ans = ans - func() ; 68 mm++; 69 } 70 71 cout << ans << endl ; 72 return 0 ; 73 74 }
1 /* 2 ID:xiekeyi1 3 PROG:crypt1 4 LANG:C++ 5 */ 6 7 #include<bits/stdc++.h> 8 using namespace std ; 9 int a[100]; 10 set<int> b ; 11 12 bool judge( int n ) 13 { 14 while( n != 0 ) 15 { 16 if( !b.count( n % 10 ) ) 17 return false ; 18 n /= 10 ; 19 } 20 21 return true ; 22 } 23 24 25 int main() 26 { 27 freopen("crypt1.in","r",stdin); 28 freopen("crypt1.out","w",stdout); 29 int n ; 30 cin >> n ; 31 for( int i = 1 ; i <= n ; i++) 32 { 33 cin >> a[i]; 34 b.insert(a[i]) ; 35 } 36 37 int ans = 0 ; 38 39 int q = 0 , w = 0 , e = 0 ; 40 for( int i = 1 ; i <= n ; i++) 41 { 42 for( int j = 1 ; j <= n ; j++) 43 { 44 for( int k = 1 ; k <= n ; k++) 45 { 46 for( int l = 1 ; l <= n ; l++) 47 { 48 for( int m = 1 ; m <= n ; m++) 49 { 50 q = ( a[i] * 100 + a[j] * 10 + a[k] ) * a[m] ; 51 w = ( a[i] * 100 + a[j] * 10 + a[k] ) * a[l]; 52 e = ( a[i] * 100 + a[j] * 10 + a[k] ) * ( a[l] * 10 + a[m] ) ; 53 if( w < 1000 && q < 1000 && e < 10000 && judge(q) && judge(w) && judge(e) ) 54 { 55 ans++; 56 //cout << q << ‘ ‘ << w << ‘ ‘ << e << endl ; 57 } 58 59 } 60 } 61 } 62 } 63 } 64 65 cout << ans << endl ; 66 return 0 ; 67 }
/* ID:xiekeyi1 PROG:combo LANG:C++ */ #include<bits/stdc++.h> using namespace std ; int n ; int john[4] , master[4]; int similar( int a , int b ) { if( a >= n - 1 && b <= n -1 ) return min( abs( a - b ) , abs( a - n - b ) ) ; if( b >= n - 1 && a <= n - 1 ) return min( abs( a - b ) , abs( b - n - a ) ) ; return abs( a - b ) ; } //int s( int a[] , int b ) //{ // int minn = 99999999 ; // for( int i = 1 ; i <= 3 ; i++ ) // minn = min( minn , similar( b , a[i] ) ) ; // // return minn ; //} bool judge( int a , int b , int c ) { int cnt = 0 ; if( similar( john[1] , a ) <= 2 ) cnt++; if( similar( john[2] , b ) <= 2 ) cnt++; if( similar( john[3] , c ) <= 2 ) cnt++; if( cnt == 3 ) return true ; cnt = 0 ; if( similar( master[1] , a ) <= 2 ) cnt++; if( similar( master[2] , b ) <= 2 ) cnt++; if( similar( master[3] , c ) <= 2 ) cnt++; if( cnt == 3 ) return true ; return false ; } int main() { freopen("combo.in","r",stdin); freopen("combo.out","w",stdout); cin >> n ; cin >> john[1] >> john[2] >> john[3] >> master[1] >> master[2] >> master[3] ; int ans = 0 ; for( int i = 1 ; i <= n ; i++ ) { for( int j = 1 ; j <= n ; j++) { for( int k = 1 ; k <= n ; k++) { if( judge( i , j , k ) ) { ans++ ; // cout << i << ‘ ‘ << j << ‘ ‘ << k << endl ; } } } } cout << ans << endl ; return 0 ; }
1 /* 2 ID:xiekeyi1 3 PROG:wormhole 4 LANG:C++ 5 */ 6 7 #include<bits/stdc++.h> 8 using namespace std ; 9 int n ; 10 int ans = 0 ; 11 int b[15] ; 12 struct node 13 { 14 int x , y ; 15 }a[15]; 16 17 bool cmp( struct node a , struct node b ) 18 { 19 if( a.y < b.y ) 20 return 1 ; 21 else if( a.y == b.y) 22 return a.x < b.x ; 23 else 24 return false ; 25 } 26 27 28 29 bool doit( int num , int x , int begin , int into ) 30 { 31 if( num != 1 && begin == x && into == 0 ) 32 return true ; 33 else if( into == 0 ) 34 { 35 if( a[x].y == a[x+1].y ) 36 { 37 return doit( num+1,x+1,begin,1 ); 38 } 39 else 40 return false ; 41 } 42 43 else 44 { 45 return doit( num+1, b[x] , begin , 0 ) ; 46 } 47 } 48 49 50 bool judge() 51 { 52 for( int i = 1 ; i <= n ; i++) 53 if( doit( 1 , i , i , 0 ) == 1 ) 54 return true ; 55 return false ; 56 } 57 58 void mpair( int x ) 59 { 60 if ( x == n + 1 ) 61 { 62 if( judge() == 1) 63 ans++; 64 return ; 65 } 66 67 else if( b[x] == 0 ) 68 { 69 for( int i = x + 1 ; i <= n ; i++) 70 { 71 if( b[i] == 0 ) 72 { 73 b[x] = i ; 74 b[i] = x ; 75 mpair(x+1); 76 b[x] = 0 ; 77 b[i] = 0 ; 78 } 79 } 80 } 81 82 else 83 mpair(x+1); 84 } 85 86 int main() 87 { 88 freopen("wormhole.in","r",stdin); 89 freopen("wormhole.out","w",stdout); 90 cin >> n ; 91 for( int i = 1 ; i <= n ; i++) 92 cin >> a[i].x >> a[i].y ; 93 sort(a+1,a+1+n,cmp) ; 94 95 mpair(1); 96 cout << ans << endl ; 97 return 0 ; 98 }
1 /* 2 ID:xiekeyi1 3 PROG: skidesign 4 LANG:C++ 5 */ 6 7 #include<bits/stdc++.h> 8 using namespace std ; 9 const int maxn = 1010 ; 10 int a[maxn]; 11 12 13 int main() 14 { 15 freopen("skidesign.in","r",stdin); 16 freopen("skidesign.out","w",stdout); 17 int n ; 18 int ans = 0x7FFFFFFF; 19 20 cin >> n ; 21 for( int i = 1 ; i <= n ; i++) 22 cin >> a[i] ; 23 sort( a+1 , a+1+n ) ; 24 for( int i = a[1] ; i <= a[n] ; i++) 25 { 26 int temp = 0 ; 27 for( int j = 1 ; j <= n ; j++) 28 { 29 if( a[j] < i ) 30 temp+= static_cast<int> ( pow( abs( i - a[j] ) , 2 ) ) ; 31 if( a[j] > i + 17 ) 32 temp += static_cast<int> ( pow( abs( i + 17 - a[j] ) , 2 ) ) ; 33 } 34 35 ans = min( ans , temp ) ; 36 } 37 cout << ans << endl ; 38 return 0 ; 39 }
标签:pen stdin sizeof section i++ while open count ast
原文地址:http://www.cnblogs.com/xiekeyi98/p/6764899.html