답안 #19470

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19470 2016-02-24T13:24:51 Z nosiar Σ (kriii4_P2) C++
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <tuple>
using namespace std;
long long mod = 1000000007;
long long m;
long long n[10000];
long long s[10000];
tuple<long long, long long, long long> extended_gcd(long long a, long long b)
{
    if (b == 0)
        return tuple<long long, long long, long long> { a, 1, 0 };

    auto r = extended_gcd(b, a % b);

    long long d = get<0>(r);
    long long x = get<1>(r);
    long long y = get<2>(r);

    return tuple<long long, long long, long long>{ d, y, x - a/b*y };
}

/* a has a (unique) multiplicative inverse iif gcd(a,n)=1 */
long long inverse(long long a)
{
    auto r = extended_gcd(a, mod);
    if (get<0>(r) != 1) return -1;
    return get<1>(r);
}
int main() {
	cin >> m;
	long long ans = 0;
	for(int i = 0; i < m; ++i)
		cin>>n[i]>>s[i];
	long long a=0,b=1;
	for(int i = 0; i < m; ++i)
		b = (b*n[i])%mod;
	for(int i = 0; i < m; ++i)
		a = (a + ((s[i] * b % mod) * inverse(n[i]) %mod))%mod;
	cout << (a*inverse(b))%mod << endl;
	
	return 0;
}

Compilation message

In file included from /usr/include/c++/4.9/tuple:35:0,
                 from P2.cpp:2:
/usr/include/c++/4.9/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
P2.cpp:8:1: error: ‘tuple’ does not name a type
 tuple<long long, long long, long long> extended_gcd(long long a, long long b)
 ^
P2.cpp: In function ‘long long int inverse(long long int)’:
P2.cpp:25:5: warning: ‘auto’ changes meaning in C++11; please remove it [-Wc++0x-compat]
     auto r = extended_gcd(a, mod);
     ^
P2.cpp:25:10: error: ‘r’ does not name a type
     auto r = extended_gcd(a, mod);
          ^
P2.cpp:26:9: error: ‘get’ was not declared in this scope
     if (get<0>(r) != 1) return -1;
         ^
P2.cpp:26:16: error: ‘r’ was not declared in this scope
     if (get<0>(r) != 1) return -1;
                ^
P2.cpp:27:12: error: ‘get’ was not declared in this scope
     return get<1>(r);
            ^
P2.cpp:27:19: error: ‘r’ was not declared in this scope
     return get<1>(r);
                   ^
P2.cpp: In function ‘int main()’:
P2.cpp:31:12: warning: unused variable ‘ans’ [-Wunused-variable]
  long long ans = 0;
            ^
P2.cpp: In function ‘long long int inverse(long long int)’:
P2.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^