本文整理汇总了C++中IV::end方法的典型用法代码示例。如果您正苦于以下问题:C++ IV::end方法的具体用法?C++ IV::end怎么用?C++ IV::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IV
的用法示例。
在下文中一共展示了IV::end方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
// Returns the number of containers required to move all the milk, with at
// most "c" in each container
int f(int c)
{
int ret = 0;
IVi it = acap.begin();
int lim = c;
while (true) {
if (*it > lim) return INF;
it = upper_bound(it, acap.end(), lim);
++ret;
if (it == acap.end()) return ret;
lim = *(it - 1) + c;
}
return -1;
}
示例2: main
int main()
{
prime_sieve ( );
int x, ok;
while ( scanf ( "%d", &x ) != EOF ) {
ok = 1;
if ( x < 5 ) printf ( "%d is not the sum of two primes!\n", x );
else if ( x & 1 ) {
if ( is_prime(x-2) ) printf ( "%d is the sum of %d and %d.\n", x, 2, x-2 );
else printf ( "%d is not the sum of two primes!\n", x );
}
else {
IV :: iterator it = upper_bound ( primes.begin(), primes.end(), x/2 );
for ( ; it != primes.end(); ++it )
if ( is_prime(x-*it) ) {
printf ( "%d is the sum of %d and %d.\n", x, x-*it, *it );
ok = 0;
break;
}
if ( ok ) printf ( "%d is not the sum of two primes!\n", x );
}
}
return 0;
}
示例3: main
int main()
{
//cout << sqrt ( 1000 ) << endl;
prime_sieve ( );
int n, c, from, to, len, i;
while ( scanf ( "%d%d", &n, &c ) != EOF ) {
printf ( "%d %d:", n, c );
len = upper_bound ( primes.begin(), primes.end(), n ) - primes.begin();
if ( len&1 ) from = len/2-(c-1), to = len/2+(c-1);
else from = len/2-c, to = len/2+(c-1);
from = max ( 0, from ); to = min ( len-1, to );
for ( i = from; i < to; ++i ) printf ( " %d", primes[i] );
printf ( " %d\n\n", primes[i] );
}
return 0;
}
示例4: test_case
void test_case()
{
int n = rand() % (MAXN - 2) + 3;
int MaxEdges = min(n*(n-1)/2, MAXM);
int m = rand() % (MaxEdges + 1);
if (m < n - 1) m = n - 1;
printf("\n%d %d\n", n, m);
IV ls;
IIS s;
for (int i = 0; i < n; ++i)
ls.push_back(i);
random_shuffle(ls.begin(), ls.end());
printf("%d %d\n", ls[0], ls[1]); --m;
int u = ls[0], v = ls[1];
if (u > v) swap(u, v);
s.insert(II(u, v));
for (int i = 2; i < n; ++i) {
u = ls[rand() % i], v = ls[i];
printf("%d %d\n", u, v); --m;
if (u > v) swap(u, v);
s.insert(II(u, v));
}
while (m--) {
int u, v;
do {
u = rand() % n;
v = rand() % n;
if (u > v) swap(u, v);
} while (u == v || s.find(II(u, v)) != s.end());
s.insert(II(u, v));
if (rand() % 2 == 0) swap(u, v);
printf("%d %d\n", u, v);
}
}