template < int n, int i, int b> struct IsPrimeIter;
template < int n, int i>
struct IsPrimeIter< n, i, 0 > {
enum _ { Value = 0 } ;
} ;
template < int n, int i>
struct IsPrimeIter< n, i, 1 > {
enum _ { Value = 1 } ;
} ;
template < int n, int i>
struct IsPrimeIter< n, i, 2 > {
enum _ { Value = IsPrimeIter< n, i+ 2 ,
( i * i > n) ? 1 :
n % i == 0 ? 0 : 2 > :: Value } ;
} ;
template < int n>
struct IsPrime {
enum _ { Value = n <= 1 ? false :
( n == 2 || n == 3 ) ? true :
( n % 2 == 0 ) ? false :
IsPrimeIter< n, 3 , 2 > :: Value } ;
} ;
#include <iostream>
int main( ) {
std:: cout << IsPrime< 1000000007 > :: Value ;
}
dGVtcGxhdGUgPGludCBuLCBpbnQgaSwgaW50IGI+IHN0cnVjdCBJc1ByaW1lSXRlcjsKCnRlbXBsYXRlIDxpbnQgbiwgaW50IGk+CnN0cnVjdCBJc1ByaW1lSXRlcjxuLCBpLCAwPiB7CiAgICBlbnVtIF8geyBWYWx1ZSA9IDAgfTsKfTsKCnRlbXBsYXRlIDxpbnQgbiwgaW50IGk+CnN0cnVjdCBJc1ByaW1lSXRlcjxuLCBpLCAxPiB7CiAgICBlbnVtIF8geyBWYWx1ZSA9IDEgfTsKfTsKCnRlbXBsYXRlIDxpbnQgbiwgaW50IGk+CnN0cnVjdCBJc1ByaW1lSXRlcjxuLCBpLCAyPiB7CiAgICBlbnVtIF8geyBWYWx1ZSA9IElzUHJpbWVJdGVyPG4sIGkrMiwgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGkgKiBpID4gbikgPyAxIDogCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbiAlIGkgPT0gMCA/IDAgOiAyPjo6VmFsdWUgfTsKfTsKCnRlbXBsYXRlIDxpbnQgbj4Kc3RydWN0IElzUHJpbWUgewogICAgZW51bSBfIHsgVmFsdWUgPSBuIDw9IDEgPyBmYWxzZToKICAgICAgICAgICAgICAgICAgICAgKG4gPT0gMiB8fCBuID09IDMpID8gdHJ1ZToKICAgICAgICAgICAgICAgICAgICAgKG4gJSAyID09IDApID8gZmFsc2UgOgogICAgICAgICAgICAgICAgICAgICBJc1ByaW1lSXRlcjxuLCAzLCAyPjo6VmFsdWUgfTsKfTsKI2luY2x1ZGUgPGlvc3RyZWFtPgppbnQgbWFpbigpIHsKCXN0ZDo6Y291dCA8PCBJc1ByaW1lPDEwMDAwMDAwMDc+OjpWYWx1ZTsKfQ==
compilation info
prog.cpp: In instantiation of 'struct IsPrimeIter<1000000007, 1799, 2>':
prog.cpp:15:10: recursively required from 'struct IsPrimeIter<1000000007, 5, 2>'
prog.cpp:15:10: required from 'struct IsPrimeIter<1000000007, 3, 2>'
prog.cpp:24:35: required from 'struct IsPrime<1000000007>'
prog.cpp:29:34: required from here
prog.cpp:15:10: fatal error: template instantiation depth exceeds maximum of 900 (use -ftemplate-depth= to increase the maximum)
enum _ { Value = IsPrimeIter<n, i+2,
^
compilation terminated.
stdout