submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s261884646
p00711
C++
#include<cstdio> #include<cstdlib> #include<iostream> #include<string> #include<map> #include<vector> #include<algorithm> #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) using namespace std; int ans = 0; void bfs(char **tile, int w, int h){ ans++; tile[w][h] = '#'; if(tile[w][h-1] == '.') bfs(tile, w, h-1); if(tile[w][h+1] == '.') bfs(tile, w, h+1); if(tile[w-1][h] == '.') bfs(tile, w-1, h); if(tile[w+1][h] == '.') bfs(tile, w+1, h); return; } int main(){ int W,H,index_w,index_h; while(true){ cin >> W >> H; if(W == 0 && H == 0) break; char **tile; tile = new char* [H+2]; REP(i,H+2) tile[i] = new char[W+2]; REP(i,H+2){ REP(j,W+2){ if(i == 0 || i == H+1 || j == 0 || j == W+1) tile[i][j] = '#'; //sentry? else scanf(" %c",&tile[i][j]); if(tile[i][j] == '@') { index_h = j; index_w = i; } } } count = 0; bfs(tile,index_w,index_h); REP(i,H) delete[] tile[i]; delete[] tile; cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:59:13: error: overloaded function with no contextual type information 59 | count = 0; | ^
s383230775
p00711
C++
// Red and Black.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include "stdafx.h" #include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<queue> using namespace std; typedef long long ll; //Global int x, y; const int MAX_N = 20; char maze[MAX_N][MAX_N]; const int INF = 1000000; int X, Y;//"@"??????????????? int memo[MAX_N][MAX_N]; int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; int counter; void bsd(int a, int b) { maze[b][a] = '#'; memo[b][a] = INF; counter++; for (int i = 0; i < 4; i++) { int nx = a + dx[i]; int ny = b + dy[i]; if (memo[ny][nx] == 0 && maze[ny][nx] == '.' && 0 <= nx && nx < x && 0 <= ny && ny < y) { bsd(nx, ny); } } } //solve //??±???????????¢?´¢??§"@"??¨???????????£?????????"."????????°????±??????? void solve() { //memo???????????? for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { memo[i][j] = 0; } } //"@"??¨??£??\???????????? ?????? INF??§?????? ?????? ????????????????????£?????????????????????"."??§?????? counter = 0;//"@"?????? bsd(X, Y); cout << counter << endl; } /* void solve() { for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cout << maze[i][j]; } cout << endl; } cout << "@???????????????" << X << Y << endl; } */ //main int main() { while (true) { cin >> x >> y; if (x == 0 && y == 0)break; //"W"??¨"."??¨"@"?????\??? for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cin >> maze[i][j]; if (maze[i][j] == '@') { X = j; Y = i;//@???????????????????¨???? } } } solve(); } return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s367410951
p00711
C++
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<queue> using namespace std; typedef long long ll; //Global int x, y; const int MAX_N = 20; char maze[MAX_N][MAX_N+1]; const int INF = 1000000; int X, Y;//"@"??????????????? int memo[MAX_N][MAX_N]; int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; int counter; void bsd(int a, int b) { maze[b][a] = '#'; memo[b][a] = INF; counter++; for (int i = 0; i < 4; i++) { int nx = a + dx[i]; int ny = b + dy[i]; if (memo[ny][nx] == 0 && maze[ny][nx] == '.' && 0 <= nx && nx < x && 0 <= ny && ny < y) { bsd(nx, ny); } } } //solve //??±???????????¢?´¢??§"@"??¨???????????£?????????"."????????°????±??????? void solve() { //memo???????????? memset(memo.0, sizeof(memo)); //for (int i = 0; i < y; i++) { //for (int j = 0; j < x; j++) { //memo[i][j] = 0; // } //} //"@"??¨??£??\???????????? ?????? INF??§?????? ?????? ????????????????????£?????????????????????"."??§?????? counter = 0;//"@"?????? bsd(X, Y); cout << counter << endl; } //main int main() { while (true) { cin >> x >> y; if (x == 0 && y == 0)break; //"W"??¨"."??¨"@"?????\??? for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cin >> maze[i][j]; if (maze[i][j] == '@') { X = j; Y = i;//@???????????????????¨???? } } } solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:40:20: error: expected ')' before numeric constant 40 | memset(memo.0, sizeof(memo)); | ~ ^~ | ) a.cc:40:9: error: 'memset' was not declared in this scope 40 | memset(memo.0, sizeof(memo)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<queue> +++ |+#include <cstring> 6 | using namespace std;
s406285543
p00711
C++
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<queue> using namespace std; typedef long long ll; //Global int x, y; const int MAX_N = 20; char maze[MAX_N][MAX_N+1]; const int INF = 1000000; int X, Y;//"@"??????????????? int memo[MAX_N][MAX_N]; int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; int counter; void bsd(int a, int b) { maze[b][a] = '#'; memo[b][a] = INF; counter++; for (int i = 0; i < 4; i++) { int nx = a + dx[i]; int ny = b + dy[i]; if (memo[ny][nx] == 0 && maze[ny][nx] == '.' && 0 <= nx && nx < x && 0 <= ny && ny < y) { bsd(nx, ny); } } } //solve //??±???????????¢?´¢??§"@"??¨???????????£?????????"."????????°????±??????? void solve() { //memo???????????? memset(memo,0, sizeof(memo)); //for (int i = 0; i < y; i++) { //for (int j = 0; j < x; j++) { //memo[i][j] = 0; // } //} //"@"??¨??£??\???????????? ?????? INF??§?????? ?????? ????????????????????£?????????????????????"."??§?????? counter = 0;//"@"?????? bsd(X, Y); cout << counter << endl; } //main int main() { while (true) { cin >> x >> y; if (x == 0 && y == 0)break; //"W"??¨"."??¨"@"?????\??? for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cin >> maze[i][j]; if (maze[i][j] == '@') { X = j; Y = i;//@???????????????????¨???? } } } solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:40:9: error: 'memset' was not declared in this scope 40 | memset(memo,0, sizeof(memo)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<queue> +++ |+#include <cstring> 6 | using namespace std;
s779324249
p00711
C++
#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<queue> using namespace std; typedef long long ll; //Global int x, y; const int MAX_N = 20; char maze[MAX_N][MAX_N+1]; const int INF = 1000000; int X, Y;//"@"??????????????? int memo[MAX_N][MAX_N]; int dx[4] = { 1,0,-1,0 }; int dy[4] = { 0,1,0,-1 }; int counter; void bsd(int a, int b) { maze[b][a] = '#'; memo[b][a] = INF; counter++; for (int i = 0; i < 4; i++) { int nx = a + dx[i]; int ny = b + dy[i]; if (memo[ny][nx] == 0 && maze[ny][nx] == '.' && 0 <= nx && nx < x && 0 <= ny && ny < y) { bsd(nx, ny); } } } //solve //??±???????????¢?´¢??§"@"??¨???????????£?????????"."????????°????±??????? void solve() { //memo???????????? memset(memo,0, sizeof(memo)); //for (int i = 0; i < y; i++) { //for (int j = 0; j < x; j++) { //memo[i][j] = 0; // } //} //"@"??¨??£??\???????????? ?????? INF??§?????? ?????? ????????????????????£?????????????????????"."??§?????? counter = 0;//"@"?????? bsd(X, Y); cout << counter << endl; } //main int main() { while (true) { cin >> x >> y; if (x == 0 && y == 0)break; //"W"??¨"."??¨"@"?????\??? for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { cin >> maze[i][j]; if (maze[i][j] == '@') { X = j; Y = i;//@???????????????????¨???? } } } solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:40:9: error: 'memset' was not declared in this scope 40 | memset(memo,0, sizeof(memo)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<queue> +++ |+#include <cstring> 6 | using namespace std;
s431818503
p00711
C++
#include <iostream> #include <math.h> #include <queue> #include <cstdio> using namespace std; int W, H; char c[100][101]; bool visited[100][100]; int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; void computer(){ memset(visited,false,sizeof visited); queue<int> que; int i, j; for(i=0;i<H;i++){ for(j=0;j<W;j++){ if(c[i][j]=='@'){ que.push(j+i*W); visited[i][j] = true; goto Skip; } } } Skip:; int answer = 1; while( !que.empty()){ int cur = que.front(); que.pop(); int x = cur % W, y = cur / W; for(i=0;i<4;++i){ int nx = x + dx[i],ny = y + dy[i]; if(!(0<=nx && nx < W && 0<=ny && ny<H))continue; if(c[ny][nx]=='#' || visited[ny][nx])continue; que.push(nx+ny*W); visited[ny][nx]=true; ++answer; } } cout << answer << endl; } // abcdd // efgeg int main(){ while(cin >> W >> H, W==0&&H==0){ int i; for(i=0;i<H;++i){ //cin >> c[i][0]; scanf(" %s",&c[i][0]); } computer(); } return 0; }
a.cc: In function 'void computer()': a.cc:14:5: error: 'memset' was not declared in this scope 14 | memset(visited,false,sizeof visited); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <cstdio> +++ |+#include <cstring> 5 | using namespace std;
s130457185
p00711
C++
//??¨??¢?´¢:??±???????????¢?´¢??????????????¢?´¢ //??????????????¢?????¬????????? //?????°??¢??°???????????????(?????????)????????\???(?????????) #include <stdio.h> #include <queue> #include <string.h> using namespace std; int W,H; char c[101][101]; bool visited[100][100]; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; void compute();//????????????????????£?¨? int main(){ while(scanf("%d %d",&W,&H),W |H){ int i; for(i=0;i<H;i++){ scanf(" %s",&c[i][0]); } } return 0; } void compute(){ memset(visited,false,sizeof visited); //{????????????????????????1bit??????????????????1bit????????§?????????} queue<int> que; int i,j; for(j=0;j<W;j++){ for(i=0;i<H;i++){ if(c[i][j]=='@'){ que.push(j+i*H); visited[i][j]=true; break; } } } int answer=1; while(!que.empty()){ int cur=que.front(); que.pop(); int x=cur%H; int y=cur/H; for(i=0;i<4;i++){ int nx=x+dx[i],ny=y+dy[i]; if(!(0<=nx&&nx<W&&0<=ny&&ny<H))continue; if(c[ny][nx]=='#'||visited[ny][nx])continue; que.push(nx+ny*H); visited[ny][nx]=true; ++answer; } } cout << answer << endl; }
a.cc: In function 'void compute()': a.cc:67:2: error: 'cout' was not declared in this scope 67 | cout << answer << endl; | ^~~~ a.cc:9:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 8 | #include <string.h> +++ |+#include <iostream> 9 | using namespace std; a.cc:67:20: error: 'endl' was not declared in this scope 67 | cout << answer << endl; | ^~~~ a.cc:9:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 8 | #include <string.h> +++ |+#include <ostream> 9 | using namespace std;
s534168278
p00711
C++
#include<iostream> using namespace std; int main(){ while(1){ int dfs(int x,int y,int count); int w,h; int dx[4]={0,-1,0,1}; int dy[4]={-1,0,1,0}; int sum=0; char maps[21][21]; int main(){ int sx,sy; cin >> h >> w; if(h==0 && w==0) break; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin >> maps[i][j]; if(maps[i][j]=='@'){ sy=i; sx=j; } } } int ans = dfs(sx,sy,0); cout << ans << endl; } int dfs(int x,int y,int count){ int nx,ny; for(int i=0;i<4;i++){ nx=x+dx[i]; ny=y+dy[i]; maps[y][x]='#'; if(0<=nx && nx<w && 0<=ny && ny<h && maps[ny][nx]!='#'){ sum++; dfs(nx,ny,count+1); } } return sum; } } return(0); }
a.cc: In function 'int main()': a.cc:13:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 13 | int main(){ | ^~ a.cc:13:13: note: remove parentheses to default-initialize a variable 13 | int main(){ | ^~ | -- a.cc:13:13: note: or replace parentheses with braces to value-initialize a variable a.cc:13:15: error: a function-definition is not allowed here before '{' token 13 | int main(){ | ^ a.cc:30:35: error: a function-definition is not allowed here before '{' token 30 | int dfs(int x,int y,int count){ | ^
s766120724
p00711
C++
1>------ テ」ツδ禿」ツδォテ」ツδ嘉ゥツ鳴凝・ツァツ? テ」ツδ療」ツδュテ」ツつクテ」ツつァテ」ツつッテ」ツδ?4_3, テヲツァツ凝ヲツ按?Debug Win32 ------ 1> Source3.cpp 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?==========
a.cc:1:10: error: extended character 」 is not valid in an identifier 1 | 1>------ テ」ツδ禿」ツδォテ」ツδ嘉ゥツ鳴凝・ツァツ? テ」ツδ療」ツδュテ」ツつクテ」ツつァテ」ツつッテ」ツδ?4_3, テヲツァツ凝ヲツ按?Debug Win32 ------ | ^ a.cc:1:10: error: extended character 」 is not valid in an identifier a.cc:1:10: error: extended character 」 is not valid in an identifier a.cc:1:53: error: extended character 」 is not valid in an identifier 1 | 1>------ テ」ツδ禿」ツδォテ」ツδ嘉ゥツ鳴凝・ツァツ? テ」ツδ療」ツδュテ」ツつクテ」ツつァテ」ツつッテ」ツδ?4_3, テヲツァツ凝ヲツ按?Debug Win32 ------ | ^ a.cc:1:53: error: extended character 」 is not valid in an identifier a.cc:1:53: error: extended character 」 is not valid in an identifier a.cc:1:53: error: extended character 」 is not valid in an identifier a.cc:1:53: error: extended character 」 is not valid in an identifier a.cc:1:53: error: extended character 」 is not valid in an identifier a.cc:3:22: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:28: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:36: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:46: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:58: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:67: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:3:73: error: stray '\' in program 3 | 1> 4_3.vcxproj -> C:\Users\hokiken\Documents\programming\contest5\Debug\4_3.exe | ^ a.cc:4:12: error: extended character 」 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:12: error: extended character 」 is not valid in an identifier a.cc:4:12: error: extended character 」 is not valid in an identifier a.cc:4:39: error: extended character 」 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:39: error: extended character 、 is not valid in an identifier a.cc:4:84: error: extended character 」 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:91: error: extended character 、 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:91: error: extended character 」 is not valid in an identifier a.cc:4:120: error: extended character 、 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:161: error: extended character 」 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:168: error: extended character 」 is not valid in an identifier 4 | ========== テ」ツδ禿」ツδォテ」ツδ? 1 テヲツュツ」テ・ツクツクテァツオツづ、ツコツ?」ツ?? テ・ツ、ツアテヲツ閉療」ツ?? テヲツ崢エテヲツ鳴ーテ、ツクツ催ィツヲツ?」ツ?? テ」ツつケテ」ツつュテ」ツδε」ツδ?========== | ^ a.cc:4:168: error: extended character 」 is not valid in an identifier a.cc:4:168: error: extended character 」 is not valid in an identifier a.cc:4:168: error: extended character 」 is not valid in an identifier a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1>------ テ」ツδ禿」ツδォテ」ツδ嘉ゥツ鳴凝・ツァツ? テ」ツδ療」ツδュテ」ツつクテ」ツつァテ」ツつッテ」ツδ?4_3, テヲツァツ凝ヲツ按?Debug Win32 ------ | ^
s615006279
p00711
C++
#include <iostream> #include <queue> using namespace std; struct locate{ int x; int y; }; char graph[20][20]; int cou = 0; int H,W; void bfs(locate z){ queue<locate> Q; locate u; locate v; Q.push(z); while(!Q.empty()){ u = Q.front();Q.pop(); if(u.y < H - 1){ if(graph[u.y + 1][u.x] == '.' && graph[u.y + 1][u.x] != 'N'){ graph[u.y + 1][u.x] = 'N'; cou++; v.y = u.y + 1; v.x = u.x; Q.push(v); } } if(u.x < W - 1){ if(graph[u.y][u.x + 1] == '.' && graph[u.y][u.x + 1] != 'N'){ graph[u.y][u.x + 1] = 'N'; cou++; v.x = u.x + 1; v.y = u.y; Q.push(v); } } if(u.y > 0){ if(graph[u.y - 1][u.x] == '.' && graph[u.y - 1][u.x] != 'N'){ graph[u.y - 1][u.x] = 'N'; cou++; v.x = u.x; v.y = u.y - 1; Q.push(v); } } if(u.x > 0){ if(graph[u.y][u.x - 1] == '.' && graph[u.y][u.x - 1] != 'N'){ graph[u.y][u.x - 1] = 'N'; cou++; v.x = u.x - 1; v.y = u.y; Q.push(v); } } /* cout << endl; for(int i = 0; i< H ;i++){ for(int j = 0; j < W; j++){ cout << graph[i][j]; } cout << endl;*/ } } } int main(){ int a1,a2; locate a; while(1){ cin >> W >> H; if(W == 0 && H == 0) break; for(int i = 0; i< H ;i++){ for(int j = 0; j < W; j++){ cin >> graph[i][j]; if(graph[i][j] == '@'){ a1 = i; a2 = j; } } } /* for(int i = 0; i< H ;i++){ for(int j = 0; j < W; j++){ cout << graph[i][j]; } cout << endl; } */ a.y = a1; a.x = a2; bfs(a); cout << cou+1 << endl; cou = 0; for(int i = 0;i < H ;i++){ for(int j = 0;j < W; j++){ graph[i][j] = 'N'; } } cou = 0; } return 0; }
a.cc:71:1: error: expected declaration before '}' token 71 | } | ^
s784923922
p00711
C++
#include <bits/stdc++.h> #define REP(i,a) for(int i=0;i<(a);i++) #define MOD 1000000007 int main(){ while(1){ int h,w; cin>>w>>h; if(h==0&&w==0) break; char a[h][w]; queue<pair<int,int>> q; bool used[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; used[i][j]=0; if(a[i][j]=='@') q.push(make_pair(i,j)); } } int ans=0; while(!q.empty()){ pair<int,int> p=q.front(); q.pop(); int x=p.first, y=p.second; if(used[x][y]) continue; used[x][y]=1; ans++; if(x>0){ if(!used[x-1][y]&&a[x-1][y]=='.'){ q.push(make_pair(x-1,y)); } } if(x<h-1){ if(!used[x+1][y]&&a[x+1][y]=='.'){ q.push(make_pair(x+1,y)); } } if(y>0){ if(!used[x][y-1]&&a[x][y-1]=='.'){ q.push(make_pair(x,y-1)); } } if(y<w-1){ if(!used[x][y+1]&&a[x][y+1]=='.'){ q.push(make_pair(x,y+1)); } } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 8 | cin>>w>>h; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:11:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 11 | queue<pair<int,int>> q; | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:11:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 11 | queue<pair<int,int>> q; | ^~~~ | std::pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here 89 | struct pair; | ^~~~ a.cc:11:16: error: expected primary-expression before 'int' 11 | queue<pair<int,int>> q; | ^~~ a.cc:17:26: error: 'q' was not declared in this scope 17 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^ a.cc:17:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 17 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:21:12: error: 'q' was not declared in this scope 21 | while(!q.empty()){ | ^ a.cc:22:12: error: expected primary-expression before 'int' 22 | pair<int,int> p=q.front(); | ^~~ a.cc:24:13: error: 'p' was not declared in this scope 24 | int x=p.first, y=p.second; | ^ a.cc:25:18: error: 'y' was not declared in this scope 25 | if(used[x][y]) continue; | ^ a.cc:26:15: error: 'y' was not declared in this scope 26 | used[x][y]=1; | ^ a.cc:30:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 30 | q.push(make_pair(x-1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:35:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 35 | q.push(make_pair(x+1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:40:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 40 | q.push(make_pair(x,y-1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:45:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 45 | q.push(make_pair(x,y+1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:49:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 49 | cout<<ans<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:49:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 49 | cout<<ans<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s047034634
p00711
C++
#include <bits/stdc++.h> #define REP(i,a) for(int i=0;i<(a);i++) #define MOD 1000000007 int main(){ while(1){ int h,w; cin>>w>>h; if(h==0&&w==0) break; char a[h][w]; queue<pair<int,int>> q; bool used[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; used[i][j]=0; if(a[i][j]=='@') q.push(make_pair(i,j)); } } int ans=0; while(!q.empty()){ pair<int,int> p=q.front(); q.pop(); int x=p.first, y=p.second; if(used[x][y]) continue; used[x][y]=1; ans++; if(x>0){ if(!used[x-1][y]&&a[x-1][y]=='.'){ q.push(make_pair(x-1,y)); } } if(x<h-1){ if(!used[x+1][y]&&a[x+1][y]=='.'){ q.push(make_pair(x+1,y)); } } if(y>0){ if(!used[x][y-1]&&a[x][y-1]=='.'){ q.push(make_pair(x,y-1)); } } if(y<w-1){ if(!used[x][y+1]&&a[x][y+1]=='.'){ q.push(make_pair(x,y+1)); } } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 8 | cin>>w>>h; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:11:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 11 | queue<pair<int,int>> q; | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:11:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 11 | queue<pair<int,int>> q; | ^~~~ | std::pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here 89 | struct pair; | ^~~~ a.cc:11:16: error: expected primary-expression before 'int' 11 | queue<pair<int,int>> q; | ^~~ a.cc:17:26: error: 'q' was not declared in this scope 17 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^ a.cc:17:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 17 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:21:12: error: 'q' was not declared in this scope 21 | while(!q.empty()){ | ^ a.cc:22:12: error: expected primary-expression before 'int' 22 | pair<int,int> p=q.front(); | ^~~ a.cc:24:13: error: 'p' was not declared in this scope 24 | int x=p.first, y=p.second; | ^ a.cc:25:18: error: 'y' was not declared in this scope 25 | if(used[x][y]) continue; | ^ a.cc:26:15: error: 'y' was not declared in this scope 26 | used[x][y]=1; | ^ a.cc:30:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 30 | q.push(make_pair(x-1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:35:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 35 | q.push(make_pair(x+1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:40:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 40 | q.push(make_pair(x,y-1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:45:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 45 | q.push(make_pair(x,y+1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:49:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 49 | cout<<ans<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:49:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 49 | cout<<ans<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s088005701
p00711
C++
#include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<stack> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<bitset> #include<stdlib.h> #include<cassert> #include<time.h> #include<bitset> int main(){ while(1){ int h,w; cin>>w>>h; if(h==0&&w==0) break; char a[h][w]; queue<pair<int,int>> q; bool used[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; used[i][j]=0; if(a[i][j]=='@') q.push(make_pair(i,j)); } } int ans=0; while(!q.empty()){ pair<int,int> p=q.front(); q.pop(); int x=p.first, y=p.second; if(used[x][y]) continue; used[x][y]=1; ans++; if(x>0){ if(!used[x-1][y]&&a[x-1][y]=='.'){ q.push(make_pair(x-1,y)); } } if(x<h-1){ if(!used[x+1][y]&&a[x+1][y]=='.'){ q.push(make_pair(x+1,y)); } } if(y>0){ if(!used[x][y-1]&&a[x][y-1]=='.'){ q.push(make_pair(x,y-1)); } } if(y<w-1){ if(!used[x][y+1]&&a[x][y+1]=='.'){ q.push(make_pair(x,y+1)); } } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:21:5: error: 'cin' was not declared in this scope; did you mean 'sin'? 21 | cin>>w>>h; | ^~~ | sin a.cc:24:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 24 | queue<pair<int,int>> q; | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from a.cc:4: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:24:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 24 | queue<pair<int,int>> q; | ^~~~ | std::pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/math.h:36, from a.cc:2: /usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here 89 | struct pair; | ^~~~ a.cc:24:16: error: expected primary-expression before 'int' 24 | queue<pair<int,int>> q; | ^~~ a.cc:30:26: error: 'q' was not declared in this scope 30 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^ a.cc:30:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 30 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:34:12: error: 'q' was not declared in this scope 34 | while(!q.empty()){ | ^ a.cc:35:12: error: expected primary-expression before 'int' 35 | pair<int,int> p=q.front(); | ^~~ a.cc:37:13: error: 'p' was not declared in this scope 37 | int x=p.first, y=p.second; | ^ a.cc:38:18: error: 'y' was not declared in this scope 38 | if(used[x][y]) continue; | ^ a.cc:39:15: error: 'y' was not declared in this scope 39 | used[x][y]=1; | ^ a.cc:43:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 43 | q.push(make_pair(x-1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:48:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 48 | q.push(make_pair(x+1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:53:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 53 | q.push(make_pair(x,y-1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:58:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 58 | q.push(make_pair(x,y+1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:62:5: error: 'cout' was not declared in this scope 62 | cout<<ans<<endl; | ^~~~ a.cc:62:16: error: 'endl' was not declared in this scope 62 | cout<<ans<<endl; | ^~~~
s230751961
p00711
C++
#include<iostream> #include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<stack> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<bitset> #include<stdlib.h> #include<cassert> #include<time.h> #include<bitset> int main(){ while(1){ int h,w; cin>>w>>h; if(h==0&&w==0) break; char a[h][w]; queue<pair<int,int>> q; bool used[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; used[i][j]=0; if(a[i][j]=='@') q.push(make_pair(i,j)); } } int ans=0; while(!q.empty()){ pair<int,int> p=q.front(); q.pop(); int x=p.first, y=p.second; if(used[x][y]) continue; used[x][y]=1; ans++; if(x>0){ if(!used[x-1][y]&&a[x-1][y]=='.'){ q.push(make_pair(x-1,y)); } } if(x<h-1){ if(!used[x+1][y]&&a[x+1][y]=='.'){ q.push(make_pair(x+1,y)); } } if(y>0){ if(!used[x][y-1]&&a[x][y-1]=='.'){ q.push(make_pair(x,y-1)); } } if(y<w-1){ if(!used[x][y+1]&&a[x][y+1]=='.'){ q.push(make_pair(x,y+1)); } } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 22 | cin>>w>>h; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:25:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 25 | queue<pair<int,int>> q; | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:25:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 25 | queue<pair<int,int>> q; | ^~~~ | std::pair In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41: /usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here 3013 | struct pair; | ^~~~ a.cc:25:16: error: expected primary-expression before 'int' 25 | queue<pair<int,int>> q; | ^~~ a.cc:31:26: error: 'q' was not declared in this scope 31 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^ a.cc:31:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 31 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^~~~~~~~~ | std::make_pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:35:12: error: 'q' was not declared in this scope 35 | while(!q.empty()){ | ^ a.cc:36:12: error: expected primary-expression before 'int' 36 | pair<int,int> p=q.front(); | ^~~ a.cc:38:13: error: 'p' was not declared in this scope 38 | int x=p.first, y=p.second; | ^ a.cc:39:18: error: 'y' was not declared in this scope 39 | if(used[x][y]) continue; | ^ a.cc:40:15: error: 'y' was not declared in this scope 40 | used[x][y]=1; | ^ a.cc:44:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 44 | q.push(make_pair(x-1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:49:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 49 | q.push(make_pair(x+1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:54:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 54 | q.push(make_pair(x,y-1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:59:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 59 | q.push(make_pair(x,y+1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:63:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 63 | cout<<ans<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:63:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 63 | cout<<ans<<endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s083794683
p00711
C++
#include<iostream> #include<stdio.h> #include<math.h> #include<algorithm> #include<queue> #include<deque> #include<stack> #include<string> #include<string.h> #include<vector> #include<set> #include<map> #include<bitset> #include<stdlib.h> #include<cassert> #include<time.h> #include<bitset> int main(){ while(1){ int h,w; cin>>w>>h; if(h==0&&w==0) break; char a[h][w]; queue<pair<int,int>> q; bool used[h][w]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>a[i][j]; used[i][j]=0; if(a[i][j]=='@') q.push(make_pair(i,j)); } } int ans=0; while(!q.empty()){ pair<int,int> p=q.front(); q.pop(); int x=p.first, y=p.second; if(used[x][y]) continue; used[x][y]=1; ans++; if(x>0){ if(!used[x-1][y]&&a[x-1][y]=='.'){ q.push(make_pair(x-1,y)); } } if(x<h-1){ if(!used[x+1][y]&&a[x+1][y]=='.'){ q.push(make_pair(x+1,y)); } } if(y>0){ if(!used[x][y-1]&&a[x][y-1]=='.'){ q.push(make_pair(x,y-1)); } } if(y<w-1){ if(!used[x][y+1]&&a[x][y+1]=='.'){ q.push(make_pair(x,y+1)); } } } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 22 | cin>>w>>h; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:25:5: error: 'queue' was not declared in this scope; did you mean 'std::queue'? 25 | queue<pair<int,int>> q; | ^~~~~ | std::queue In file included from /usr/include/c++/14/queue:66, from a.cc:5: /usr/include/c++/14/bits/stl_queue.h:96:11: note: 'std::queue' declared here 96 | class queue | ^~~~~ a.cc:25:11: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 25 | queue<pair<int,int>> q; | ^~~~ | std::pair In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41: /usr/include/c++/14/bits/stl_iterator.h:3013:12: note: 'std::pair' declared here 3013 | struct pair; | ^~~~ a.cc:25:16: error: expected primary-expression before 'int' 25 | queue<pair<int,int>> q; | ^~~ a.cc:31:26: error: 'q' was not declared in this scope 31 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^ a.cc:31:33: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 31 | if(a[i][j]=='@') q.push(make_pair(i,j)); | ^~~~~~~~~ | std::make_pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:35:12: error: 'q' was not declared in this scope 35 | while(!q.empty()){ | ^ a.cc:36:12: error: expected primary-expression before 'int' 36 | pair<int,int> p=q.front(); | ^~~ a.cc:38:13: error: 'p' was not declared in this scope 38 | int x=p.first, y=p.second; | ^ a.cc:39:18: error: 'y' was not declared in this scope 39 | if(used[x][y]) continue; | ^ a.cc:40:15: error: 'y' was not declared in this scope 40 | used[x][y]=1; | ^ a.cc:44:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 44 | q.push(make_pair(x-1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:49:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 49 | q.push(make_pair(x+1,y)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:54:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 54 | q.push(make_pair(x,y-1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:59:18: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 59 | q.push(make_pair(x,y+1)); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:63:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 63 | cout<<ans<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:63:16: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 63 | cout<<ans<<endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s992562854
p00711
C++
#include "bits/stdc++.h" using std::cin; using std::cout; int cnt = 0; char map[21][21]; void dfs(int x, int y, int mx, int my){ if((x < 0) || (x >= mx)){ return; } if((y < 0) || (y >= my)){ return; } if(map[x][y] == '#'){ return; } map[x][y] = '#'; cnt++; dfs(x+1, y, mx, my); dfs(x-1, y, mx, my); dfs(x, y+1, mx, my); dfs(x, y-1, mx, my); } int main(){ int W, H, sx, sy; cin >> W >> H; while(W != 0 && H != 0){ for(int i = 0; i < H; i++){ scanf("%20s", map[i]); if(std::string(map[i]).find('@') != std::string::npos){ sx = i; sy = std::string(map[i]).find('@'); } } dfs(sx, sy, H, W); cout << cnt << std::endl; cin >> W >> H; cnt = 0; }
a.cc: In function 'int main()': a.cc:44:6: error: expected '}' at end of input 44 | } | ^ a.cc:26:11: note: to match this '{' 26 | int main(){ | ^
s798934868
p00711
C++
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" using namespace std; using ll = long long int; #define debug(v) {printf("L%d %s > ",__LINE__,#v);cout<<(v)<<endl;} #define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){cout<<e<<" ";}cout<<endl;} #define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;} #define debugaa(m,h,w) {printf("L%d %s >\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}} #define ALL(v) (v).begin(),(v).end() #define repeat(cnt,l) for(remove_const<decltype(l)>::type cnt=0;(cnt)<(l);++(cnt)) #define rrepeat(cnt,l) for(auto cnt=(l)-1;0<=(cnt);--(cnt)) #define iterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);++(cnt)) #define diterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);--(cnt)) const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; template<typename T1, typename T2> inline void assert_equal(T1 expected, T2 actual) { if (!(expected == actual)) { cerr << "assertion fault: expected=" << expected << " actual=" << actual << endl; abort(); } } template<typename T1, typename T2> inline void assert_less(T1 actual, T2 threshold) { if (!(actual < threshold)) { cerr << "assertion fault: " << actual << " < (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline void assert_eqless(T1 actual, T2 threshold) { if (!(actual <= threshold)) { cerr << "assertion fault: " << actual << " <= (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } template<typename Vec> inline ostream& _ostream_vecprint(ostream &o, const Vec& p) { o << '['; for (auto& e : p) o << e << ','; o << ']'; return o; } template<typename T> inline ostream& operator<<(ostream& o, const vector<T>& v) { return _ostream_vecprint(o, v); } template<typename T, size_t S> inline ostream& operator<<(ostream& o, const array<T, S>& v) { return _ostream_vecprint(o, v); } template<typename T> inline T& maxset(T& to, const T& val) { return to = max(to, val); } template<typename T> inline T& minset(T& to, const T& val) { return to = min(to, val); } void bye(string s, int code = 0) { cout << s << endl; exit(code); } mt19937_64 randdev(8901016); template<typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); } template<> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); } template<> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); } #if defined(_WIN32) || defined(_WIN64) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #elif defined(__GNUC__) #else #define getchar_unlocked getchar #define putchar_unlocked putchar #endif namespace { #define isvisiblechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template<typename T> void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'<cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var * sign; } inline int c() { return getchar_unlocked(); } inline MaiScanner& operator>>(int& var) { input_integer<int>(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer<long long>(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiblechar(cc); cc = getchar_unlocked()); for (; isvisiblechar(cc); cc = getchar_unlocked()) var.push_back(cc); return *this; } template<typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; class MaiPrinter { public: template<typename T> void output_integer(T var) { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) putchar_unlocked('-'), var = -var; char stack[32]; int stack_p = 0; while (var) stack[stack_p++] = '0' + (var % 10), var /= 10; while (stack_p) putchar_unlocked(stack[--stack_p]); } inline MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } inline MaiPrinter& operator<<(int var) { output_integer<int>(var); return *this; } inline MaiPrinter& operator<<(long long var) { output_integer<long long>(var); return *this; } inline MaiPrinter& operator<<(char* str_p) { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } inline MaiPrinter& operator<<(const string& str) { const char* p = str.c_str(); const char* l = p + str.size(); while (p < l) putchar_unlocked(*p++); return *this; } template<typename IT> void join(IT begin, IT end, char sep = '\n') { for (auto it = begin; it != end; ++it) *this << *it << sep; } }; } MaiScanner scanner; MaiPrinter printer; struct P { using T = int; T y, x; P(T _y = 0, T _x = 0) :y(_y), x(_x) {} inline bool operator == (P p) const { return y == p.y && x == p.x; } inline bool operator < (P p) const { return y == p.y ? x < p.x : y < p.y; } inline P operator+(P p) const { return P(y + p.y, x + p.x); } inline P operator-(P p) const { return P(y - p.y, x - p.x); } inline P operator+=(P p) { y += p.y; x += p.x; return *this; } inline P operator-=(P p) { y -= p.y; x -= p.x; return *this; } }; template<typename T> // using T = int; struct F { int height, width; vector<T> data; F(int h = 1, int w = 1) :height(h), width(w), data(h*w) {} inline T& operator()(int y, int x) { return data[x + y * width]; } inline T& operator()(P p) { return data[p.x + p.y * width]; } inline T operator()(int y, int x) const { return data[x + y * width]; } inline T operator()(P p) const { return data[p.x + p.y * width]; } inline bool safe(int y, int x) const { return 0 <= y && y < height && 0 <= x && x < width; } inline bool safe(P p) const { return 0 <= p.y && p.y < height && 0 <= p.x && p.x < width; } inline void fill(T e) { std::fill(ALL(data), e); } inline void resize(int h, int w) { height = h; width = w; data.resize(h*w); } void print(ostream& os, int setw_arg = 4) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) os << setw(setw_arg) << operator()(y, x) << ' '; os << '\n'; } } }; int moving[][2] = { {0,1},{1,0},{-1,0},{0,1} }; int solve() { int H, W; scanner >> H >> W; if (H == 0 && W == 0) return 1; F<int> field(H, W); P start; repeat(y, H) { string str; scanner >> str; repeat(x, W) { field(y, x) = !(str[x] == '#'); if (str[x] == '@') start = P(y, x); } } queue<P> q; q.push(start); ll ans = 1; while (!q.empty()) { P p = q.front(); q.pop(); for (auto mv : moving) { int vy = mv[0], vx = mv[1]; if (field.safe(p + P(vy, vx)) && field(p + P(vy, vx))) { q.push(p + P(vy, vx)); ans += 1; field(p + P(vy, vx)) = 0; } } } printer << ans << endl; return 0; } int main() { while (!solve()); return 0; }
a.cc: In function 'int solve()': a.cc:181:20: error: no match for 'operator<<' (operand types are '{anonymous}::MaiPrinter' and '<unresolved overloaded function type>') 181 | printer << ans << endl; | ~~~~~~~~~~~~~~~^~~~~~~ a.cc:81:28: note: candidate: '{anonymous}::MaiPrinter& {anonymous}::MaiPrinter::operator<<(char)' 81 | inline MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } | ^~~~~~~~ a.cc:81:44: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'char' 81 | inline MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } | ~~~~~^ a.cc:82:28: note: candidate: '{anonymous}::MaiPrinter& {anonymous}::MaiPrinter::operator<<(int)' 82 | inline MaiPrinter& operator<<(int var) { output_integer<int>(var); return *this; } | ^~~~~~~~ a.cc:82:43: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 82 | inline MaiPrinter& operator<<(int var) { output_integer<int>(var); return *this; } | ~~~~^~~ a.cc:83:28: note: candidate: '{anonymous}::MaiPrinter& {anonymous}::MaiPrinter::operator<<(long long int)' 83 | inline MaiPrinter& operator<<(long long var) { output_integer<long long>(var); return *this; } | ^~~~~~~~ a.cc:83:49: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 83 | inline MaiPrinter& operator<<(long long var) { output_integer<long long>(var); return *this; } | ~~~~~~~~~~^~~ a.cc:84:28: note: candidate: '{anonymous}::MaiPrinter& {anonymous}::MaiPrinter::operator<<(char*)' 84 | inline MaiPrinter& operator<<(char* str_p) { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } | ^~~~~~~~ a.cc:84:45: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'char*' 84 | inline MaiPrinter& operator<<(char* str_p) { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } | ~~~~~~^~~~~ a.cc:85:28: note: candidate: '{anonymous}::MaiPrinter& {anonymous}::MaiPrinter::operator<<(const std::string&)' 85 | inline MaiPrinter& operator<<(const string& str) { | ^~~~~~~~ a.cc:85:53: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} 85 | inline MaiPrinter& operator<<(const string& str) { | ~~~~~~~~~~~~~~^~~ a.cc:21:52: note: candidate: 'template<class T1, class T2> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)' 21 | template<typename T1, typename T2> inline ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } | ^~~~~~~~ a.cc:21:52: note: template argument deduction/substitution failed: a.cc:181:23: note: couldn't deduce template parameter 'T1' 181 | printer << ans << endl; | ^~~~ a.cc:23:38: note: candidate: 'template<class T> std::ostream& operator<<(std::ostream&, const std::vector<_Tp>&)' 23 | template<typename T> inline ostream& operator<<(ostream& o, const vector<T>& v) { return _ostream_vecprint(o, v); } | ^~~~~~~~ a.cc:23:38: note: template argument deduction/substitution failed: a.cc:181:23: note: couldn't deduce template parameter 'T' 181 | printer << ans << endl; | ^~~~ a.cc:24:48: note: candidate: 'template<class T, long unsigned int S> std::ostream& operator<<(std::ostream&, const std::array<_Tp, _Nm>&)' 24 | template<typename T, size_t S> inline ostream& operator<<(ostream& o, const array<T, S>& v) { return _ostream_vecprint(o, v); } | ^~~~~~~~ a.cc:24:48: note: template argument deduction/substitution failed: a.cc:181:23: note: couldn't deduce template parameter 'T' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:3: /usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)' 1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:181:23: note: couldn't deduce template parameter '_IntegerType' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ /usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)' 1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/c++/14/bits/ios_base.h:46, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/c++/14/memory:80, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56: /usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)' 70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans << endl; | ^~~~ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:181:23: note: '{anonymous}::MaiPrinter' is not derived from 'std::basic_ostream<_CharT, _Traits>' 181 | printer << ans
s758050524
p00711
C++
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" using namespace std; using ll = long long int; #define debug(v) {printf("L%d %s > ",__LINE__,#v);cout<<(v)<<endl;} #define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){cout<<e<<" ";}cout<<endl;} #define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;} #define debugaa(m,h,w) {printf("L%d %s >\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}} #define ALL(v) (v).begin(),(v).end() #define repeat(cnt,l) for(remove_const<decltype(l)>::type cnt=0;(cnt)<(l);++(cnt)) #define rrepeat(cnt,l) for(auto cnt=(l)-1;0<=(cnt);--(cnt)) #define iterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);++(cnt)) #define diterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);--(cnt)) const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; template<typename T1, typename T2> inline void assert_equal(T1 expected, T2 actual) { if (!(expected == actual)) { cerr << "assertion fault: expected=" << expected << " actual=" << actual << endl; abort(); } } template<typename T1, typename T2> inline void assert_less(T1 actual, T2 threshold) { if (!(actual < threshold)) { cerr << "assertion fault: " << actual << " < (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline void assert_eqless(T1 actual, T2 threshold) { if (!(actual <= threshold)) { cerr << "assertion fault: " << actual << " <= (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } template<typename Vec> inline ostream& _ostream_vecprint(ostream &o, const Vec& p) { o << '['; for (auto& e : p) o << e << ','; o << ']'; return o; } template<typename T> inline ostream& operator<<(ostream& o, const vector<T>& v) { return _ostream_vecprint(o, v); } template<typename T, size_t S> inline ostream& operator<<(ostream& o, const array<T, S>& v) { return _ostream_vecprint(o, v); } template<typename T> inline T& maxset(T& to, const T& val) { return to = max(to, val); } template<typename T> inline T& minset(T& to, const T& val) { return to = min(to, val); } void bye(string s, int code = 0) { cout << s << endl; exit(code); } mt19937_64 randdev(8901016); template<typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); } template<> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); } template<> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); } #if defined(_WIN32) || defined(_WIN64) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #elif defined(__GNUC__) #else #define getchar_unlocked getchar #define putchar_unlocked putchar #endif namespace { #define isvisiblechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template<typename T> void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'<cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var * sign; } inline int c() { return getchar_unlocked(); } inline MaiScanner& operator>>(int& var) { input_integer<int>(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer<long long>(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiblechar(cc); cc = getchar_unlocked()); for (; isvisiblechar(cc); cc = getchar_unlocked()) var.push_back(cc); return *this; } template<typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; class MaiPrinter { public: template<typename T> void output_integer(T var) { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) putchar_unlocked('-'), var = -var; char stack[32]; int stack_p = 0; while (var) stack[stack_p++] = '0' + (var % 10), var /= 10; while (stack_p) putchar_unlocked(stack[--stack_p]); } inline MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } inline MaiPrinter& operator<<(int var) { output_integer<int>(var); return *this; } inline MaiPrinter& operator<<(long long var) { output_integer<long long>(var); return *this; } inline MaiPrinter& operator<<(char* str_p) { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } inline MaiPrinter& operator<<(const string& str) { const char* p = str.c_str(); const char* l = p + str.size(); while (p < l) putchar_unlocked(*p++); return *this; } template<typename IT> void join(IT begin, IT end, char sep = '\n') { for (auto it = begin; it != end; ++it) *this << *it << sep; } }; } MaiScanner scanner; MaiPrinter printer; struct P { using T = int; T y, x; P(T _y = 0, T _x = 0) :y(_y), x(_x) {} inline bool operator == (P p) const { return y == p.y && x == p.x; } inline bool operator < (P p) const { return y == p.y ? x < p.x : y < p.y; } inline P operator+(P p) const { return P(y + p.y, x + p.x); } inline P operator-(P p) const { return P(y - p.y, x - p.x); } inline P operator+=(P p) { y += p.y; x += p.x; return *this; } inline P operator-=(P p) { y -= p.y; x -= p.x; return *this; } }; template<typename T> // using T = int; struct F { int height, width; vector<T> data; F(int h = 1, int w = 1) :height(h), width(w), data(h*w) {} inline T& operator()(int y, int x) { return data[x + y * width]; } inline T& operator()(P p) { return data[p.x + p.y * width]; } inline T operator()(int y, int x) const { return data[x + y * width]; } inline T operator()(P p) const { return data[p.x + p.y * width]; } inline bool safe(int y, int x) const { return 0 <= y && y < height && 0 <= x && x < width; } inline bool safe(P p) const { return 0 <= p.y && p.y < height && 0 <= p.x && p.x < width; } inline void fill(T e) { std::fill(ALL(data), e); } inline void resize(int h, int w) { height = h; width = w; data.resize(h*w); } void print(ostream& os, int setw_arg = 4) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) os << setw(setw_arg) << operator()(y, x) << ' '; os << '\n'; } } }; int moving[][2] = { {0,1},{1,0},{-1,0},{0,1} }; int solve() { int H, W; scanner >> H >> W; if (H == 0 && W == 0) return 1; F<int> field(H, W); P start; repeat(y, H) { string str; scanner >> str; repeat(x, W) { field(y, x) = !(str[x] == '#'); if (str[x] == '@') start = P(y, x); } } queue<P> q; q.push(start); ll ans = 1; while (!q.empty()) { P p = q.front(); q.pop(); for (auto mv : moving) { int vy = mv[0], vx = mv[1]; if (field.safe(p + P(vy, vx)) && field(p + P(vy, vx))) { q.push(p + P(vy, vx)); ans += 1; field(p + P(vy, vx)) = 0; } } } printer << ans << '\n'; return 0; } int main() { while (!solve()); return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:3: /usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:186:14: note: called from here 186 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
s871201642
p00711
C++
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" using namespace std; using ll = long long int; #define debug(v) {printf("L%d %s > ",__LINE__,#v);cout<<(v)<<endl;} #define debugv(v) {printf("L%d %s > ",__LINE__,#v);for(auto e:(v)){cout<<e<<" ";}cout<<endl;} #define debuga(m,w) {printf("L%d %s > ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;} #define debugaa(m,h,w) {printf("L%d %s >\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[y][x]<<" ";}cout<<endl;}} #define ALL(v) (v).begin(),(v).end() #define repeat(cnt,l) for(remove_const<decltype(l)>::type cnt=0;(cnt)<(l);++(cnt)) #define rrepeat(cnt,l) for(auto cnt=(l)-1;0<=(cnt);--(cnt)) #define iterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);++(cnt)) #define diterate(cnt,b,e) for(auto cnt=(b);(cnt)!=(e);--(cnt)) const ll MD = 1000000007ll; const long double PI = 3.1415926535897932384626433832795L; template<typename T1, typename T2> inline void assert_equal(T1 expected, T2 actual) { if (!(expected == actual)) { cerr << "assertion fault: expected=" << expected << " actual=" << actual << endl; abort(); } } template<typename T1, typename T2> inline void assert_less(T1 actual, T2 threshold) { if (!(actual < threshold)) { cerr << "assertion fault: " << actual << " < (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline void assert_eqless(T1 actual, T2 threshold) { if (!(actual <= threshold)) { cerr << "assertion fault: " << actual << " <= (const)" << threshold << endl; abort(); } } template<typename T1, typename T2> inline ostream& operator <<(ostream &o, const pair<T1, T2> p) { o << '(' << p.first << ':' << p.second << ')'; return o; } template<typename Vec> inline ostream& _ostream_vecprint(ostream &o, const Vec& p) { o << '['; for (auto& e : p) o << e << ','; o << ']'; return o; } template<typename T> inline ostream& operator<<(ostream& o, const vector<T>& v) { return _ostream_vecprint(o, v); } template<typename T, size_t S> inline ostream& operator<<(ostream& o, const array<T, S>& v) { return _ostream_vecprint(o, v); } template<typename T> inline T& maxset(T& to, const T& val) { return to = max(to, val); } template<typename T> inline T& minset(T& to, const T& val) { return to = min(to, val); } void bye(string s, int code = 0) { cout << s << endl; exit(code); } mt19937_64 randdev(8901016); template<typename T> inline T rand(T l, T h) { return uniform_int_distribution<T>(l, h)(randdev); } template<> inline double rand<double>(double l, double h) { return uniform_real_distribution<double>(l, h)(randdev); } template<> inline float rand<float>(float l, float h) { return uniform_real_distribution<float>(l, h)(randdev); } #if defined(_WIN32) || defined(_WIN64) #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #elif defined(__GNUC__) #else #define getchar_unlocked getchar #define putchar_unlocked putchar #endif namespace { #define isvisiblechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template<typename T> void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'<cc; cc = getchar_unlocked()) if (cc == '-') sign = -1; for (; '0' <= cc && cc <= '9'; cc = getchar_unlocked()) var = (var << 3) + (var << 1) + cc - '0'; var = var * sign; } inline int c() { return getchar_unlocked(); } inline MaiScanner& operator>>(int& var) { input_integer<int>(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer<long long>(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiblechar(cc); cc = getchar_unlocked()); for (; isvisiblechar(cc); cc = getchar_unlocked()) var.push_back(cc); return *this; } template<typename IT> void in(IT begin, IT end) { for (auto it = begin; it != end; ++it) *this >> *it; } }; class MaiPrinter { public: template<typename T> void output_integer(T var) { if (var == 0) { putchar_unlocked('0'); return; } if (var < 0) putchar_unlocked('-'), var = -var; char stack[32]; int stack_p = 0; while (var) stack[stack_p++] = '0' + (var % 10), var /= 10; while (stack_p) putchar_unlocked(stack[--stack_p]); } inline MaiPrinter& operator<<(char c) { putchar_unlocked(c); return *this; } inline MaiPrinter& operator<<(int var) { output_integer<int>(var); return *this; } inline MaiPrinter& operator<<(long long var) { output_integer<long long>(var); return *this; } inline MaiPrinter& operator<<(char* str_p) { while (*str_p) putchar_unlocked(*(str_p++)); return *this; } inline MaiPrinter& operator<<(const string& str) { const char* p = str.c_str(); const char* l = p + str.size(); while (p < l) putchar_unlocked(*p++); return *this; } template<typename IT> void join(IT begin, IT end, char sep = '\n') { for (auto it = begin; it != end; ++it) *this << *it << sep; } }; } MaiScanner scanner; MaiPrinter printer; struct P { using T = int; T y, x; P(T _y = 0, T _x = 0) :y(_y), x(_x) {} inline bool operator == (P p) const { return y == p.y && x == p.x; } inline bool operator < (P p) const { return y == p.y ? x < p.x : y < p.y; } inline P operator+(P p) const { return P(y + p.y, x + p.x); } inline P operator-(P p) const { return P(y - p.y, x - p.x); } inline P operator+=(P p) { y += p.y; x += p.x; return *this; } inline P operator-=(P p) { y -= p.y; x -= p.x; return *this; } }; template<typename T> // using T = int; struct F { int height, width; vector<T> data; F(int h = 1, int w = 1) :height(h), width(w), data(h*w) {} inline T& operator()(int y, int x) { return data[x + y * width]; } inline T& operator()(P p) { return data[p.x + p.y * width]; } inline T operator()(int y, int x) const { return data[x + y * width]; } inline T operator()(P p) const { return data[p.x + p.y * width]; } inline bool safe(int y, int x) const { return 0 <= y && y < height && 0 <= x && x < width; } inline bool safe(P p) const { return 0 <= p.y && p.y < height && 0 <= p.x && p.x < width; } inline void fill(T e) { std::fill(ALL(data), e); } inline void resize(int h, int w) { height = h; width = w; data.resize(h*w); } void print(ostream& os, int setw_arg = 4) { for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) os << setw(setw_arg) << operator()(y, x) << ' '; os << '\n'; } } }; int moving[][2] = { {0,1},{1,0},{-1,0},{0,-1} }; int solve() { int H, W; scanner >> W >> H; if (H == 0 && W == 0) return 1; F<int> field(H, W); P start; repeat(y, H) { string str; scanner >> str; repeat(x, W) { field(y, x) = !(str[x] == '#'); if (str[x] == '@') start = P(y, x); } } queue<P> q; q.push(start); field(start) = 0; ll ans = 1; while (!q.empty()) { P p = q.front(); q.pop(); for (auto mv : moving) { int vy = mv[0], vx = mv[1]; if (field.safe(p + P(vy, vx)) && field(p + P(vy, vx))) { q.push(p + P(vy, vx)); ans += 1; field(p + P(vy, vx)) = 0; } } } printer << ans << '\n'; return 0; } int main() { while (!solve()); return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:3: /usr/include/c++/14/bits/allocator.h: In destructor 'std::__cxx11::basic_string<char>::_Alloc_hider::~_Alloc_hider()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = char]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:186:14: note: called from here 186 | struct _Alloc_hider : allocator_type // TODO check __is_final | ^~~~~~~~~~~~
s920638733
p00711
C++
#include <bits/stdc++.h> using namespace std; typedef unsigned int uint; typedef long long int lint; typedef unsigned long long int ulint; //#define DEBUG #ifdef DEBUG # define dump(i) cout << "[*] " #i " : " << i << endl; # define debug(i) i void print(char map[20][20], int w, int h) { for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { cout << static_cast<int>(map[i][j]); } cout << endl; } } void print(int* arr, int size) { for (int i = 0; i < size; ++i) { cout << arr[i] << endl; } } #else # define dump(i) # define debug(i) # define print(i, j, k) # define print(j, k) #endif #define rep(i, MAX) for (int i = 0; i < (MAX); ++i) struct UnionFind { vector<int> par; UnionFind(int n): par(n) { for (int i = 0; i < n; ++i) { par[i] = i; } } int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); } bool same(int x, int y) { return find(x) == find(y); } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; par[y] = x; } }; inline void solve() { int w, h; constexpr int MAX = 20; char tile[MAX][MAX]; dump(MAX); while (true) { pair<int, int> at; cin >> w >> h; if (!w && !h) return; int table[MAX] = {}; UnionFind uf = UnionFind(200); const int asdf = MAX * MAX; dump(asdf); rep(i, h) { rep(j, w) { cin >> tile[i][j]; if (tile[i][j] == '@') { at.first = i; at.second = j; tile[i][j] = '.'; } } } int csi = 1; if (tile[0][0] == '.') { tile[0][0] = csi++; } else { tile[0][0] = 0; } table[tile[0][0]]++; for (int i = 1; i < w; ++i) { if (tile[0][i] == '.') { tile[0][i] = tile[0][i-1] != 0 ? tile[0][i-1] : csi++; } else { tile[0][i] = 0; } table[tile[0][i]]++; } rep(i, h) { if (i == 0) continue; rep(j, w) { if (j == 0) { if (tile[i][j] == '.') { tile[i][j] = tile[i-1][j] != 0 ? tile[i-1][j] : csi++; } else { tile[i][j] = 0; } } else { if (tile[i][j] == '.') { int tmp = tile[i-1][j]; if (tmp == 0) { tmp = tile[i][j-1]; } else if (tile[i][j-1] != 0) { uf.unite(tmp, tile[i][j-1]); if (tmp > tile[i][j-1]) { tmp = tile[i][j-1]; } } tile[i][j] = tmp != 0 ? tmp : csi++; } else { tile[i][j] = 0; } } table[tile[i][j]]++; } } int ans = 0; int iv = tile[at.first][at.second]; rep(i, csi) { if (uf.same(iv, i)) { ans += table[i]; } } dump("tile"); print(tile, w, h); dump("table"); print(table, csi); dump("ans"); cout << ans << endl; } } int main() { //* ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); // */ #ifdef DEBUG const auto start = chrono::high_resolution_clock::now(); #endif solve(); #ifdef DEBUG const auto stop = chrono::high_resolution_clock::now(); cerr << "[*] time: " << chrono::duration_cast<chrono::milliseconds>(stop-start).count() << " [ms]" << endl; #endif return 0; }
a.cc:29:10: warning: "print" redefined 29 | # define print(j, k) | ^~~~~ a.cc:28:10: note: this is the location of the previous definition 28 | # define print(i, j, k) | ^~~~~ a.cc:136:33: error: macro "print" passed 3 arguments, but takes just 2 136 | print(tile, w, h); | ^ a.cc:29:10: note: macro "print" defined here 29 | # define print(j, k) | ^~~~~ a.cc: In function 'void solve()': a.cc:136:17: error: 'print' was not declared in this scope 136 | print(tile, w, h); | ^~~~~
s335274859
p00711
C++
#include <iostream> #include <algorithm> using namespace std; ​ int W, H; char visit[21][21]; int dfs(int h, int w){ int sum=1; if(0>w || w==W || 0>h || h==H) return 0; if(visit[h][w]=='#') return 0; if(visit[h][w]=='!') return 0; visit[h][w] = '!'; sum += dfs(h, w+1); sum += dfs(h, w-1); sum += dfs(h+1, w); sum += dfs(h-1, w); return sum; } ​ int main(void){ int w1, h1; string str; while(cin >> W >> H){ if(W == 0 && H == 0) break; for(int i=0; i<H; i++){ cin >> str; for(int j=0; j<W; j++){ visit[i][j] = str[j]; if(visit[i][j] == '@'){ visit[i][j] = '.'; w1 = j; h1 = i; } } } cout << dfs(h1, w1) <<endl; } return 0; }
a.cc:4:1: error: '\U0000200b' does not name a type 4 | ​ | a.cc: In function 'int dfs(int, int)': a.cc:9:16: error: 'W' was not declared in this scope 9 | if(0>w || w==W || 0>h || h==H) return 0; | ^ a.cc:9:31: error: 'H' was not declared in this scope 9 | if(0>w || w==W || 0>h || h==H) return 0; | ^ a.cc: At global scope: a.cc:20:1: error: '\U0000200b' does not name a type 20 | ​ |
s913948406
p00711
C++
int main() { int W, H, i, j, f, d, count; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; char map[32][32]; char s[32]; while (1) { gets(s); sscanf(s, "%d %d", &W, &H); if (W == 0 && H == 0) { break; } for (i = 0; i < 30; i++) { strcpy(map[i], "##############################"); } for (i = 0; i < H; i++) { gets(&map[i+1][1]); map[i+1][W+1] = '#'; map[i+1][W+2] = '\0'; } count = 1; while (1) { f = 0; for (i = 1; i <= H; i++) { for (j = 1; j <= W; j++) { if (map[i][j] == '@') { for (d = 0; d < 4; d++) { if (map[i+dy[d]][j+dx[d]] == '.') { map[i+dy[d]][j+dx[d]] = '@'; count++; f = 1; } } } } } if (!f) { break; } } printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:10:5: error: 'gets' was not declared in this scope 10 | gets(s); | ^~~~ a.cc:11:5: error: 'sscanf' was not declared in this scope 11 | sscanf(s, "%d %d", &W, &H); if (W == 0 && H == 0) { break; } | ^~~~~~ a.cc:13:7: error: 'strcpy' was not declared in this scope 13 | strcpy(map[i], "##############################"); | ^~~~~~ a.cc:1:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | int main() a.cc:42:5: error: 'printf' was not declared in this scope 42 | printf("%d\n", count); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main()
s224913745
p00711
C++
#include <stdio.h> int main() { int W, H, i, j, f, d, count; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; char map[32][32]; char s[32]; while (1) { gets(s); sscanf(s, "%d %d", &W, &H); if (W == 0 && H == 0) { break; } for (i = 0; i < 30; i++) { strcpy(map[i], "##############################"); } for (i = 0; i < H; i++) { gets(&map[i+1][1]); map[i+1][W+1] = '#'; map[i+1][W+2] = '\0'; } count = 1; while (1) { f = 0; for (i = 1; i <= H; i++) { for (j = 1; j <= W; j++) { if (map[i][j] == '@') { for (d = 0; d < 4; d++) { if (map[i+dy[d]][j+dx[d]] == '.') { map[i+dy[d]][j+dx[d]] = '@'; count++; f = 1; } } } } } if (!f) { break; } } printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:11:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 11 | gets(s); | ^~~~ | getw a.cc:14:7: error: 'strcpy' was not declared in this scope 14 | strcpy(map[i], "##############################"); | ^~~~~~ a.cc:2:1: note: 'strcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | int main()
s146520033
p00711
C++
#include <bits/stdc++.h> using namespace std; int main() { int W, H, i, j, f, d, count; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; char map[32][32]; char s[32]; while (1) { gets(s); sscanf(s, "%d %d", &W, &H); if (W == 0 && H == 0) { break; } for (i = 0; i < 30; i++) { strcpy(map[i], "##############################"); } for (i = 0; i < H; i++) { gets(&map[i+1][1]); map[i+1][W+1] = '#'; map[i+1][W+2] = '\0'; } count = 1; while (1) { f = 0; for (i = 1; i <= H; i++) { for (j = 1; j <= W; j++) { if (map[i][j] == '@') { for (d = 0; d < 4; d++) { if (map[i+dy[d]][j+dx[d]] == '.') { map[i+dy[d]][j+dx[d]] = '@'; count++; f = 1; } } } } } if (!f) { break; } } printf("%d\n", count); } return 0; }
a.cc: In function 'int main()': a.cc:15:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 15 | gets(s); | ^~~~ | getw
s628463090
p00711
C++
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> bool c[20][20] = {} ; int cnt,w, h, p[20][20] = {}; int main() { int j, f,cx,cy; char in[20]; while (1) { for (int i = 0; i < 400; i++) { c[i / 20][i % 20] = p[i / 20][i % 20] = 0; } cnt = 0; f = 1; scanf("%d %d", &w, &h); if (w ==0&& h == 0) break; scanf("\n", &j); for (int i = 0; i < h; i++) { scanf("%s", &in); for (j = 0; j < w; j++) { switch (in[j]) { case '#': c[j][i] = 0; p[j][i] = -1; break; case '@': cx = j; cy = i; p[j][i] = 1; case '.': c[j][i] = 1; } } } /*for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) printf("%3d", c[j][i]); printf("\n"); }*/ while (f == 1) { f = 0; if (w != 1 && h != 1) { for (int i = 0; i < w*h; i++) { if (p[i / h][i%h] == 0 && (p[i / h + 1][i % h] == 1 || p[i / h - 1][i % h] == 1 || p[i / h][i % h + 1] == 1 || p[i / h][i % h - 1] == 1)) { p[i / h][i%h] = 1; f = 1; } } } if (w = 1 && h != 1) { for (int i = 0; i < w*h; i++) { if (p[i / h][i%h] == 0 && (p[i / h][i % h + 1] == 1 || p[i / h][i % h - 1] == 1)) { p[i / h][i%h] = 1; f = 1; } } } if (w != 1 && h = 1) { for (int i = 0; i < w*h; i++) { if (p[i / h][i%h] == 0 && (p[i / h + 1][i % h] == 1 || p[i / h - 1][i % h] == 1)) { p[i / h][i%h] = 1; f = 1; } } } /*for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) printf("%3d", p[j][i]); printf("\n"); } printf("\n");*/ } for (int i = 0; i < w*h; i++) { if (p[i / h][i%h] == 1) cnt++; } printf("%d\n", cnt); } return 0; }
a.cc: In function 'int main()': a.cc:61:36: error: lvalue required as left operand of assignment 61 | if (w != 1 && h = 1) { | ~~~~~~~^~~~
s321669084
p00711
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s587974974
p00711
C++
#include <string> #include <iostream> using namespace std; int w, h; bool b[20][20]; bool ok[20][20]; char dx[] = {-1, 1, 0, 0}; char dy[] = {0, 0, -1, 1}; void dfs(int x, int y){ for(int i=0;i<4;i++){ if(0<=x+dx[i]&&x+dx[i]<w&&0<=y+dy[i]&&y+dy[i]<h){ if(!b[y+dy[i]][x+dx[i]]) continue; if(ok[y+dy[i]][x+dx[i]]) continue; ok[y+dy[i]][x+dx[i]] = true; dfs(x+dx[i],y+dy[i]); } } } int main(){ while(cin >> w >> h){ if(!w) break; int x, y; string s; memset(b,false,sizeof(b)); for(int i=0;i<h;i++){ cin >> s; for(int j=0;j<w;j++){ b[i][j] = (s[j] !='#'); if(s[j]=='@') x = j, y = i; } } memset(ok,false,sizeof(ok)); ok[y][x] = true; dfs(x,y); int count = 0; for(int i=0;i<h;i++) for(int j=0;j<w;j++) count += ok[i][j]; cout << count << endl; } }
a.cc: In function 'int main()': a.cc:29:17: error: 'memset' was not declared in this scope 29 | memset(b,false,sizeof(b)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <iostream> +++ |+#include <cstring> 3 |
s433120845
p00711
C++
import java.util.*; import java.awt.Point; public class Main { static int w,h,sx,sy; static int[] dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1}; static String[] field; static boolean[][] visited; static Scanner sc = new Scanner(System.in); public static void main(String[] args) { while(read()) { System.out.println(solve()); } } static boolean read() { w = sc.nextInt(); h = sc.nextInt(); if(w == 0 && h == 0) { return false; } field = new String[h]; for(int i = 0; i < h; i++) { field[i] = sc.next(); int tmp = field[i].indexOf('@'); if(tmp != -1) { sy = i; sx = tmp; } } return true; } static int solve() { visited = new boolean[h][w]; Queue<Point> que = new LinkedList<Point>(); Point s = new Point(sx, sy); que.add(s); visited[sy][sx] = true; int ans = 1; while(!que.isEmpty()) { Point p = que.poll(); for(int i = 0; i < 4; i++) { Point next = new Point(p.x + dx[i], p.y + dy[i]); if(!inField(next) || field[next.y].charAt(next.x) == '#' || visited[next.y][next.x] == true) { continue; } else { que.add(next); visited[next.y][next.x] = true; ans++; } } } return ans; } static boolean inField(Point p) { if(p.x >= 0 && p.x < w && p.y >= 0 && p.y < h) { return true; } else { return false; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.awt.Point; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s260977152
p00711
C++
#define B(a,x,b) ((a)<=(x)&&(x)<(b)) char T[999]; int x,y,cx,cy,i,c; void R(a,b){ if(B(0,a,x)&&B(0,b,y)&&T[b*20+a]){ T[b*20+a]=0;i++;R(a-1,b);R(a+1,b);R(a,b-1);R(a,b+1); } } main(){ for(;scanf("%d%d",&x,&y),x;){ for(i=0;i<x*y;i++){ int _x=i%x, _y=i/x; for(;(c=getchar())!='\n';); switch(c){ case '@': cx=_x;cy=_y; case '.': T[_y*20+_x]=1; break; case '#': T[_y*20+_x]=0; break; } } i=0; R(cx,cy); printf("%d\n",i); } return 0; }
a.cc:6:6: error: variable or field 'R' declared void 6 | void R(a,b){ | ^ a.cc:6:8: error: 'a' was not declared in this scope 6 | void R(a,b){ | ^ a.cc:6:10: error: 'b' was not declared in this scope 6 | void R(a,b){ | ^ a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 12 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:13:14: error: 'scanf' was not declared in this scope 13 | for(;scanf("%d%d",&x,&y),x;){ | ^~~~~ a.cc:16:33: error: 'getchar' was not declared in this scope 16 | for(;(c=getchar())!='\n';); | ^~~~~~~ a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | #define B(a,x,b) ((a)<=(x)&&(x)<(b)) a.cc:24:17: error: 'R' was not declared in this scope 24 | R(cx,cy); | ^ a.cc:25:17: error: 'printf' was not declared in this scope 25 | printf("%d\n",i); | ^~~~~~ a.cc:25:17: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s519378596
p00711
C++
#define B(a,x,b) ((a)<=(x)&&(x)<(b)) char T[999]; int x,y,cx,cy,i,c; void R(int a,int b){ if(B(0,a,x)&&B(0,b,y)&&T[b*20+a]){ T[b*20+a]=0;i++;R(a-1,b);R(a+1,b);R(a,b-1);R(a,b+1); } } main(){ for(;scanf("%d%d",&x,&y),x;){ for(i=0;i<x*y;i++){ int _x=i%x, _y=i/x; for(;(c=getchar())!='\n';); switch(c){ case '@': cx=_x;cy=_y; case '.': T[_y*20+_x]=1; break; case '#': T[_y*20+_x]=0; break; } } i=0; R(cx,cy); printf("%d\n",i); } return 0; }
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 13 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:14:14: error: 'scanf' was not declared in this scope 14 | for(;scanf("%d%d",&x,&y),x;){ | ^~~~~ a.cc:17:33: error: 'getchar' was not declared in this scope 17 | for(;(c=getchar())!='\n';); | ^~~~~~~ a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | a.cc:26:17: error: 'printf' was not declared in this scope 26 | printf("%d\n",i); | ^~~~~~ a.cc:26:17: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s989801200
p00711
C++
#include <iostream> #include <cmath> #include <vector> #include <cctype> #include <algorithm> #include <string> #include <queue> using namespace std; char map[21][21]; int w, h; int tile = 0; void dfs(int x, int y){ if (!(0 <= x && x < w && 0 <= y < h)) return; tile++; map[y][x] = '#'; if (map[y-1][x] == '.') dfs(x, y-1); if (map[y+1][x] == '.') dfs(x, y+1); if (map[y][x-1] == '.') dfs(x-1, y); if (map[y][x+1] == '.') dfs(x+1, y); } int main(){ int sx, sy; while (cin >> w >> h, w || h){ memset(map, '#', sizeof(map)); tile = 0; for (int i = 0; i < h; i++){ cin >> map[i]; for (int p = 0; p < w; p++){ if (map[i][p] == '@'){ sx = p; sy = i; } } } dfs(sx, sy); cout << tile << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:9: error: 'memset' was not declared in this scope 27 | memset(map, '#', sizeof(map)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <queue> +++ |+#include <cstring> 8 | using namespace std;
s049494633
p00711
C++
#include <iostream> #include <cmath> #include <vector> #include <cctype> #include <algorithm> #include <string> #include <queue> using namespace std; char map[21][21]; int w, h; int tile = 0; void dfs(int x, int y){ if (!(0 <= x && x < w && 0 <= y < h)) return; tile++; map[y][x] = '#'; if (map[y-1][x] == '.') dfs(x, y-1); if (map[y+1][x] == '.') dfs(x, y+1); if (map[y][x-1] == '.') dfs(x-1, y); if (map[y][x+1] == '.') dfs(x+1, y); } int main(){ int sx, sy; while (cin >> w >> h, w || h){ memset(map, '#', sizeof(map)); tile = 0; for (int i = 0; i < h; i++){ cin >> map[i]; for (int p = 0; p < w; p++){ if (map[i][p] == '@'){ sx = p; sy = i; } } } dfs(sx, sy); cout << tile << endl; } return 0; }
a.cc: In function 'int main()': a.cc:27:9: error: 'memset' was not declared in this scope 27 | memset(map, '#', sizeof(map)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <queue> +++ |+#include <cstring> 8 | using namespace std;
s450879921
p00711
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; char field[20][20]; bool flag[20][20]; int W, H, ans; void dfs(int x, int y) { //field[x][y] = '.'; //cout << x << ' ' << y << endl; //cout << flag[x][y] << endl; //cout << ans << endl; for(int i = 0 ; i < 4 ; i++) { int nx = x + dx[i], ny = y + dy[i]; if(0 <= nx && nx < H && 0 <= ny && ny < W && field[nx][ny] == '.' && flag[nx][ny] == false) { ans++; flag[nx][ny] = true; dfs(nx, ny); //cout << "OK" << endl; } //else dfs(nx, ny); } } int main(void) { int x, y; int res; while(cin >> W >> H, W != 0 && H != 0) { memset(flag, false, sizeof(flag)); ans = 1; for(int i = 0 ; i < H ; i++) { for(int j = 0 ; j < W ; j++) { cin >> field[i][j]; if(field[i][j] == '@') x = i, y = j; } } /*for(int i = 0 ; i < H ; i++) { for(int j = 0 ; j < W ; j++) { cout << field[i][j]; } cout << endl; }*/ //printf("@x = %d, @y = %d\n", x, y); dfs(x, y); cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:34:5: error: 'memset' was not declared in this scope 34 | memset(flag, false, sizeof(flag)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <algorithm> +++ |+#include <cstring> 4 | using namespace std;
s146923757
p00711
C++
#include<iostream> #include<cstdio> #include<vector> using namespace std; int w,h; int ans=1; char tile[21][21]; void saiki(int x,int y){ if(x<0 | x>h | y<0 | y>w)return; tile[x][y]='#'; if(tile[x-1][y]=='.')ans++,saiki(x-1,y); if(tile[x+1][y]=='.')ans++,saiki(x+1,y); if(tile[x][y-1]=='.')ans++,saiki(x,y-1); if(tile[x][y+1]=='.')ans++,saiki(x,y+1); } int main(void){ int a,b; while(1){ scanf("%d %d",&w,&h); if(w==0 && h==0)break; ans=1; memset(tile,0,sizeof(tile)); for(a=0;a<h;a++){ scanf("%s",tile[a]); } for(a=0;a<h;a++){ for(b=0;b<w;b++){ if(tile[a][b]=='@')saiki(a,b); } } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:26:17: error: 'memset' was not declared in this scope 26 | memset(tile,0,sizeof(tile)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<vector> +++ |+#include <cstring> 4 |
s970418789
p00711
C++
#include <iostream> using namespace std; char S[21][21]; int count = 0; void a(int i, int j){ if(S[i][j] == '.'){ count++; S[i][j] = '#'; a(i - 1, j); a(i + 1, j); a(i, j + 1); a(i, j - 1); } } int main(){ while(true){ memset(S,'#',sizeof(S)); count = 0; int x, y; cin >> x >> y; if(x == 0 && y == 0){ break; } for(int i = 0; i < y; i++){ for(int j = 0; j < x; j++){ cin >> S[i][j]; } } int startx, starty; for(int i = 0; i < y; i++){ for(int j = 0; j < x; j++){ if(S[i][j] == '@'){ startx = j; starty = i; S[i][j] = '.'; break; } } } a(starty, startx); cout << count << endl; } }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(S,'#',sizeof(S)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s930765050
p00711
C++
#include<iostream> #include<string> using namespace std; int w,h; string map[40]; int vec[4][2]={{0,1},{0,-1},{-1,0},{1,0}}; void move(int x,int y){ int ans=0; map[x][y]='#'; for(int i=0;i<4;i++){ if((x+vec[i][0]>=0)&&(y+vec[i][1]>=0)&&(x+vec[i][0]<h)&&(y+vec[i][1]<w)){ if(map[x+vec[i][0]][y+vec[i][1]]=='.'){ ans+=move(x+vec[i][0],y+vec[i][1]); } } } return ans; } int main(){ while(cin>>w>>h,w){ int fx,fy; for(int i=0;i<h;i++){ cin>>map[i]; } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(map[i][j]=='@'){ fx=i; fy=j; break; } } } int ans=move(fx,fy); cout<<ans<<endl; } }
a.cc: In function 'void move(int, int)': a.cc:13:42: error: void value not ignored as it ought to be 13 | ans+=move(x+vec[i][0],y+vec[i][1]); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:17:16: error: return-statement with a value, in function returning 'void' [-fpermissive] 17 | return ans; | ^~~ a.cc: In function 'int main()': a.cc:35:29: error: void value not ignored as it ought to be 35 | int ans=move(fx,fy); | ~~~~^~~~~~~
s058426840
p00711
C++
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <queue> #include <stack> #include <string> #include <map> #include <cstdio> #include <cstdlib> #include <cmath> #define rep(i, n) for(int i = 0; i < n; i ++) #define ALL(T) T.begin(), T.end() #define mp make_pair #define pb push_back #define X first #define Y second #define MEMSET(v, h) memset((v), h, sizeof(v)) using namespace std; typedef pair<int, int> pii; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<string> vs; const int INF = 1 << 24; const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, 1, -1}; int cnt, w, h; char m[100][100]; void dfs(pii); int main(void){ while(cin >> w >> h, w){ MEMSET(m, '#'); cnt = 0; pii p; rep(y, h){ cin >> m[y]; rep(x, w) if(m[y][x] == '@') m[y][x] = '.', p = mp(x, y); } dfs(p); cout << cnt << endl; } return 0; } void dfs(pii p){ if((p.X < 0 || w <= p.X) || (p.Y < 0 || h <= p.Y)) return; if(m[p.Y][p.X] == '.') cnt ++; else return; m[p.Y][p.X] = '#'; rep(i, 4){ pii next = mp(p.X + dx[i], p.Y + dy[i]); dfs(next); } }
a.cc: In function 'int main()': a.cc:19:22: error: 'memset' was not declared in this scope 19 | #define MEMSET(v, h) memset((v), h, sizeof(v)) | ^~~~~~ a.cc:39:9: note: in expansion of macro 'MEMSET' 39 | MEMSET(m, '#'); | ^~~~~~ a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 11 | #include <cmath> +++ |+#include <cstring> 12 |
s578942302
p00711
C++
6 9 ....#. .....# ...... ...... ...... ...... ...... #@...# .#..#.
a.cc:2:5: error: stray '#' in program 2 | ....#. | ^ a.cc:3:6: error: stray '#' in program 3 | .....# | ^ a.cc:9:2: error: invalid preprocessing directive #@ 9 | #@...# | ^ a.cc:10:2: error: stray '#' in program 10 | .#..#. | ^ a.cc:10:5: error: stray '#' in program 10 | .#..#. | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 6 9 | ^
s280714517
p00711
C++
#include <iostream> #include <queue> using namespace std; typedef pair<int, int> P; char t[20][20]; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; int ans,h,w; queue<P> q; int bfs(int x, int y){ q.push( P(x, y) ); while( !q.empty() ){ P now = q.front(); q.pop(); for( int i = 0 ; i < 4 ; i++ ){ int nx = now.first + dx[i]; int ny = now.second + dy[i]; if( 0 <= nx && nx < w && 0 <= ny && ny <= h && t[ny][nx] == '.' ){ t[ny][nx] = '#'; q.push( P(nx, ny) ); ans++; } } } return ans; } int main(void){ int x,y; while( cin >> w >> h, h + w ){ memset( t, 0, sizeof(t) ); ans = 1; for( int i = 0 ; i < h ; i++ ){ for( int j = 0 ; j < w ; j++ ){ cin >> t[i][j]; if( t[i][j] == '@' ){ x = j; y = i; } } } cout << bfs(x,y) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:39:5: error: 'memset' was not declared in this scope 39 | memset( t, 0, sizeof(t) ); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <queue> +++ |+#include <cstring> 3 |
s388377895
p00711
C++
# -*- coding: utf-8 -*- count = 0 def dfs(i, j, island): global count print i, j dxy = [(1, 0), (0, 1), (-1, 0), (0, -1)] if i < 0 or i >= len(island) or j < 0 or j >= len(island[0]): return if island[i][j] == '#' or island[i][j] == 'x': return island[i][j] = 'x' count += 1 for d in dxy: dfs(i+d[0], j+d[1], island) def solve(w, h, island): s_i = 0 s_j = 0 for i, row in enumerate(island): for j, s in enumerate(row): if s == '@': s_i = i s_j = j break dfs(s_i, s_j, island) print count def func(): ''' ''' while True: global count wh = map(int, raw_input().split()) w = wh[0] h = wh[1] island = [] count = 0 for i in range(h): row = [] line = raw_input() for j in line: row.append(j) island.append(row) for row in island: for j in row: print j print '' solve(w, h, island) return None func()
a.cc:1:3: error: invalid preprocessing directive #- 1 | # -*- coding: utf-8 -*- | ^ a.cc:35:5: error: empty character constant 35 | ''' | ^~ a.cc:35:7: warning: missing terminating ' character 35 | ''' | ^ a.cc:35:7: error: missing terminating ' character a.cc:37:5: error: empty character constant 37 | ''' | ^~ a.cc:37:7: warning: missing terminating ' character 37 | ''' | ^ a.cc:37:7: error: missing terminating ' character a.cc:55:19: error: empty character constant 55 | print '' | ^~ a.cc:3:1: error: 'count' does not name a type 3 | count = 0 | ^~~~~
s812233355
p00711
C++
#include<iostream> #include<algorithm> using namespace std; int W,H; void solve(int,int); char dfs[20][20]; int d_x[]={1,0,-1,0},d_y[]={0,1,0,-1}; int main(){ while(1){ int ans=0; cin>>W>>H; if(W==0&&H==0) break; int dx,dy; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>dfs[j][i]; if(dfs[j][i]=='@'){ dx=j; dy=i; } } } solve(dx,dy); for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(dfs[j][i]=='T') ans++; cout<<ans<<endl; memset(dfs,0,sizeof(dfs)); } } void solve(int x,int y){ dfs[x][y]='T'; for(int j=0;j<4;j++){ int mx=x+d_x[j],my=y+d_y[j]; if(mx<0||my<0||mx>W||my>H) continue; if(dfs[mx][my]=='.') solve(mx,my); } }
a.cc: In function 'int main()': a.cc:32:17: error: 'memset' was not declared in this scope 32 | memset(dfs,0,sizeof(dfs)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 |
s395543315
p00711
C++
#include<iostream> #include<algorithm> using namespace std; int W,H; void solve(int,int); char dfs[20][20]; int d_x[]={1,0,-1,0},d_y[]={0,1,0,-1}; int main(){ while(1){ int ans=0; cin>>W>>H; if(W==0&&H==0) break; int dx,dy; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>dfs[j][i]; if(dfs[j][i]=='@'){ dx=j; dy=i; } } } solve(dx,dy); for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(dfs[j][i]=='T') ans++; cout<<ans<<endl; memset(dfs,0,sizeof(dfs)); } } void solve(int x,int y){ dfs[x][y]='T'; for(int j=0;j<4;j++){ int mx=x+d_x[j],my=y+d_y[j]; if(mx<0||my<0||mx>W||my>H) continue; if(dfs[mx][my]=='.') solve(mx,my); } return ; }
a.cc: In function 'int main()': a.cc:33:17: error: 'memset' was not declared in this scope 33 | memset(dfs,0,sizeof(dfs)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 |
s780108109
p00711
C++
#include<iostream> #include<algorithm> #include<memory> #include<cstdlib> using namespace std; int W,H; void solve(int,int); char dfs[20][20]; int d_x[]={1,0,-1,0},d_y[]={0,1,0,-1}; int main(){ while(1){ int ans=0; cin>>W>>H; if(W==0&&H==0) break; int dx,dy; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>dfs[j][i]; if(dfs[j][i]=='@'){ dx=j; dy=i; } } } solve(dx,dy); for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(dfs[j][i]=='T') ans++; cout<<ans<<endl; memset(dfs,0,sizeof(dfs)); } } void solve(int x,int y){ dfs[x][y]='T'; for(int j=0;j<4;j++){ int mx=x+d_x[j],my=y+d_y[j]; if(mx<0||my<0||mx>W||my>H) continue; if(dfs[mx][my]=='.') solve(mx,my); } return ; }
a.cc: In function 'int main()': a.cc:35:17: error: 'memset' was not declared in this scope 35 | memset(dfs,0,sizeof(dfs)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<cstdlib> +++ |+#include <cstring> 5 |
s655602684
p00711
C++
#include<iostream> #include<algorithm> #include<memory> #include<cstdlib> using namespace std; int W,H; void solve(int,int); char dfs[20][20]; int d_x[]={1,0,-1,0},d_y[]={0,1,0,-1}; int main(){ while(1){ int ans=0; cin>>W>>H; if(W==0&&H==0) break; int dx,dy; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>dfs[j][i]; if(dfs[j][i]=='@'){ dx=j; dy=i; } } } solve(dx,dy); for(int i=0;i<H;i++) for(int j=0;j<W;j++) if(dfs[j][i]=='T') ans++; cout<<ans<<endl; memset(dfs,0,sizeof(dfs)); } return 0; } void solve(int x,int y){ dfs[x][y]='T'; for(int j=0;j<4;j++){ int mx=x+d_x[j],my=y+d_y[j]; if(mx<0||my<0||mx>W||my>H) continue; if(dfs[mx][my]=='.') solve(mx,my); } return ; }
a.cc: In function 'int main()': a.cc:35:17: error: 'memset' was not declared in this scope 35 | memset(dfs,0,sizeof(dfs)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include<cstdlib> +++ |+#include <cstring> 5 |
s871120258
p00712
Java
#include <iostream> #include <vector> #include <math.h> #include <stdio.h> #include <algorithm> #include <string> #include <map> #include <queue> #include <memory.h> using namespace std; const int INF = 2 << 27; #define ll long long typedef pair<int,int> P; int p; int q; int a; int n; int solv(int id, int v[]); int lcm(int a, int b); int gcd(int a, int b); int main() { while(1) { cin >> p >> q >> a >> n; if(p == 0 && q == 0 && a == 0 && n == 0) break; int x[8]; int ret = solv(0,x); cout << ret << endl; } } int solv(int id, int v[]) { if(id != 0) { int pp = 1; int qq = v[0]; for(int i = 1; i < id; i++) { int llcm = lcm(qq,v[i]); int ql = llcm / qq; qq = llcm; pp *= ql; int vl = llcm / v[i]; pp += vl; } int llcm = lcm(qq,q); int ql = llcm / q; int ppx = p * ql; int qql = llcm / qq; pp *= qql; if(ppx < pp) return 0; if(ppx == pp) return 1; } if(id >= n) return 0; int Max = 1; int now = 1; for(int i = 0; i < id; i++) { now *= v[i]; Max = max(v[i], Max); } int ret = 0; int HOGE = (int)(a / now) +((a % now == 0)?1:0); for(int i = Max; i <= HOGE; i++) { v[id] = i; ret += solv(id+1,v); v[id] = 0; } return ret; } int gcd(int a, int b) { if(b > a) { return gcd(b,a); } if(b == 0) return a; return gcd(b,a % b); } int lcm(int a, int b) { return a * b / gcd(a,b); }
Main.java:1: error: illegal character: '#' #include <iostream> ^ Main.java:2: error: illegal character: '#' #include <vector> ^ Main.java:3: error: illegal character: '#' #include <math.h> ^ Main.java:4: error: illegal character: '#' #include <stdio.h> ^ Main.java:5: error: illegal character: '#' #include <algorithm> ^ Main.java:6: error: illegal character: '#' #include <string> ^ Main.java:7: error: illegal character: '#' #include <map> ^ Main.java:8: error: illegal character: '#' #include <queue> ^ Main.java:9: error: illegal character: '#' #include <memory.h> ^ Main.java:11: error: class, interface, enum, or record expected const int INF = 2 << 27; ^ Main.java:12: error: illegal character: '#' #define ll long long ^ Main.java:12: error: class, interface, enum, or record expected #define ll long long ^ Main.java:15: error: unnamed classes are a preview feature and are disabled by default. int p; ^ (use --enable-preview to enable unnamed classes) Main.java:26: error: not a statement cin >> p >> q >> a >> n; ^ Main.java:30: error: not a statement cout << ret << endl; ^ Main.java:28: error: ']' expected int x[8]; ^ 16 errors
s795513814
p00712
Java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static boolean debug = false; static void solve() { for (;;) { int p = ir.nextInt(); int q = ir.nextInt(); int a = ir.nextInt(); int n = ir.nextInt(); if (p == 0) return; out.println(dfs(p, q, 1, n, a, 1)); } } static int dfs(int p, int q, int m, int n, int a, int s) { if (n < 0) return 0; if (m > a) return 0; if (n * q < p * s) return 0; if (p == 0) return 1; if (m * s > a) return 0; int ret = 0; for (int i = s;; i++) { int pp = i * p - q, qq = q * i; if (pp < 0) continue; if (i * p - n * q > 0) break; int g = gcd(pp, qq); pp /= g; qq /= g; ret += dfs(pp, qq, m * i, n - 1, a, i); } return ret; } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) throws Exception { ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return false; } return true; } private int readByte() { if (hasNextByte()) return buffer[curbuf++]; else return -1; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (hasNextByte() && isSpaceChar(buffer[curbuf])) curbuf++; } public boolean hasNext() { skip(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) map[i] = next().toCharArray(); return map; } } static void tr(Object... o) { if (debug) out.println(Arrays.deepToString(o)); } } import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static boolean debug = false; static void solve() { for (;;) { int p = ir.nextInt(); int q = ir.nextInt(); int a = ir.nextInt(); int n = ir.nextInt(); if (p == 0) return; out.println(dfs(p, q, 1, n, a, 1)); } } static int dfs(int p, int q, int m, int n, int a, int s) { if (n < 0) return 0; if (m > a) return 0; if (n * q < p * s) return 0; if (p == 0) return 1; if (m * s > a) return 0; int ret = 0; for (int i = s;; i++) { int pp = i * p - q, qq = q * i; if (pp < 0) continue; if (i * p - n * q > 0) break; int g = gcd(pp, qq); pp /= g; qq /= g; ret += dfs(pp, qq, m * i, n - 1, a, i); } return ret; } static int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } public static void main(String[] args) throws Exception { ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return false; } return true; } private int readByte() { if (hasNextByte()) return buffer[curbuf++]; else return -1; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (hasNextByte() && isSpaceChar(buffer[curbuf])) curbuf++; } public boolean hasNext() { skip(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) map[i] = next().toCharArray(); return map; } } static void tr(Object... o) { if (debug) out.println(Arrays.deepToString(o)); } }
Main.java:197: error: class, interface, enum, or record expected import java.io.IOException; ^ Main.java:198: error: class, interface, enum, or record expected import java.io.InputStream; ^ Main.java:199: error: class, interface, enum, or record expected import java.io.PrintWriter; ^ Main.java:200: error: class, interface, enum, or record expected import java.util.Arrays; ^ Main.java:201: error: class, interface, enum, or record expected import java.util.InputMismatchException; ^ Main.java:202: error: class, interface, enum, or record expected import java.util.NoSuchElementException; ^ 6 errors
s592575084
p00712
Java
import java.util.Scanner; public class Main { static int p,q,a,n,count; public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(true){ count=0; p=sc.nextInt(); q=sc.nextInt(); a=sc.nextInt(); n=sc.nextInt(); if(p+q+a+n==0) break; s.clear(); search(1,0,0,1); System.out.println(count); } } static void search(int deno,int nume,int k,int t){ if(n<k) return; if(p*deno==q*nume){ count++; } for(int i=t;i*deno<=a;i++){ int de=deno*i; int nu=(nume*i)+deno; search(de,nu,k+1,i); } } }
Main.java:15: error: cannot find symbol s.clear(); ^ symbol: variable s location: class Main 1 error
s410151280
p00712
Java
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main1 { int p, q, a, n, cnt; void run() { Scanner sc = new Scanner(System.in); for(;;) { p = sc.nextInt(); q = sc.nextInt(); a = sc.nextInt(); n = sc.nextInt(); if( (p|q|a|n) == 0 ) break; cnt = 0; int vs[] = new int[n]; dfs(1, 0, 1, vs); System.out.println(cnt); } } void dfs( int i, int x, int mul, int[] vs) { // debug(i, x, mul, add); int sum = 0; for(int j=0;j<x;j++) sum += mul / vs[j]; if( p * mul == sum * q ) { // debug(i, x, mul, vs); cnt++; return; } if( x == n ) return; for(int j=i;j<=a;j++) { if( mul * j > a )break; vs[x] = j; dfs( j, x+1, mul*j, vs ); } } void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } public static void main(String[] args) { new Main().run(); } }
Main.java:7: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ Main.java:43: error: cannot access Main new Main().run(); ^ bad source file: ./Main.java file does not contain class Main Please remove or make sure it appears in the correct subdirectory of the sourcepath. 2 errors
s819383160
p00712
Java
public class Main { public static int dfs(int p, int q, int a, int n, int cur_pro, int prev_d){ if(n < 0){ return 0; } if(p == 0 && cur_pro <= a){ return 1; }else if(n == 0){ return 0; } int sum = 0; int divide = /* a */ a / cur_pro + 1; while(p * divide >= q){ //System.out.println("[" + n +"]" + " 1 / " + divide); if(divide * cur_pro > a){ divide--; continue; }else if(n * q < p * divide){ divide--; continue; }else if(divide < prev_d){ break; } final int upper = p * divide - q; final int downer = q * divide; sum += dfs(upper, downer, a, n - 1, cur_pro * divide, divide); divide--; } return sum; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); while(true){ StringTokenizer tok = new StringTokenizer(br.readLine()); final int p = Integer.parseInt(tok.nextToken()); final int q = Integer.parseInt(tok.nextToken()); final int a = Integer.parseInt(tok.nextToken()); final int n = Integer.parseInt(tok.nextToken()); if(p == 0 && q == 0 && a == 0 && n == 0){ break; } int sum = dfs(p, q, a, n, 1, 0); System.out.println(sum); } } }
Main.java:40: error: cannot find symbol public static void main(String[] args) throws IOException { ^ symbol: class IOException location: class Main Main.java:41: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:41: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:41: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main Main.java:44: error: cannot find symbol StringTokenizer tok = new StringTokenizer(br.readLine()); ^ symbol: class StringTokenizer location: class Main Main.java:44: error: cannot find symbol StringTokenizer tok = new StringTokenizer(br.readLine()); ^ symbol: class StringTokenizer location: class Main 6 errors
s867557835
p00712
C
#include<stdio.h> #include<stdlib.h> int func(int p, int q, double a, int n, int i) { int i; int b=0; if(n>0&&p>0){ for(i=1;i<=a;i++){ if(p*i==q){ b++; b+=func(p*i-q, a/i, n-1, i); } } } return b; } int main(void) { int p, q, a, n; while(1) { scanf("%d %d %d %d ", &p, &q, &a, &n); if(p==0&&q==0&&a==0&&n==0) break; printf("%d\n", unit(p, q, (double)a, n, 1)); } return 0; } 
main.c: In function 'func': main.c:6:9: error: 'i' redeclared as different kind of symbol 6 | int i; | ^ main.c:4:45: note: previous definition of 'i' with type 'int' 4 | int func(int p, int q, double a, int n, int i) | ~~~~^ main.c:13:20: error: too few arguments to function 'func' 13 | b+=func(p*i-q, a/i, n-1, i); | ^~~~ main.c:4:5: note: declared here 4 | int func(int p, int q, double a, int n, int i) | ^~~~ main.c: In function 'main': main.c:30:24: error: implicit declaration of function 'unit'; did you mean 'unix'? [-Wimplicit-function-declaration] 30 | printf("%d\n", unit(p, q, (double)a, n, 1)); | ^~~~ | unix main.c: At top level: main.c:34:1: error: stray '\23' in program 34 | <U+0013> | ^~~~~~~~
s563902432
p00712
C
#include<stdio.h> #include<stdlib.h> int func(int p, int q, double a, int n, int i) { int i; int b=0; if(n>0&&p>0){ for(i=1;i<=a;i++){ if(p*i==q){ b++; b+=func(p*i-q, a/i, n-1, i); } } } return b; } int main(void) { int p, q, a, n, i; while(1) { scanf("%d %d %d %d ", &p, &q, &a, &n); if(p==0&&q==0&&a==0&&n==0) break; printf("%d\n", unit(p, q, (double)a, n, 1)); } return 0; } 
main.c: In function 'func': main.c:6:9: error: 'i' redeclared as different kind of symbol 6 | int i; | ^ main.c:4:45: note: previous definition of 'i' with type 'int' 4 | int func(int p, int q, double a, int n, int i) | ~~~~^ main.c:13:20: error: too few arguments to function 'func' 13 | b+=func(p*i-q, a/i, n-1, i); | ^~~~ main.c:4:5: note: declared here 4 | int func(int p, int q, double a, int n, int i) | ^~~~ main.c: In function 'main': main.c:30:24: error: implicit declaration of function 'unit'; did you mean 'unix'? [-Wimplicit-function-declaration] 30 | printf("%d\n", unit(p, q, (double)a, n, 1)); | ^~~~ | unix main.c: At top level: main.c:34:1: error: stray '\23' in program 34 | <U+0013> | ^~~~~~~~
s569607269
p00712
C
#include<stdio.h> #include<stdlib.h> int func(int p, int q, double a, int n, int 1) { int i; int b=0; if(n>0&&p>0){ for(i=1;i<=a;i++){ if(p*i==q){ b++; } b+=func(p*i-q, q*i, a/i, n-1, i); } } return b; } int main(void) { int p, q, a, n; while(1) { scanf("%d %d %d %d ", &p, &q, &a, &n); if(p==0&&q==0&&a==0&&n==0) break; printf("%d\n", unit(p, q, (double)a, n, 1)); } return 0; }
main.c:4:45: error: expected ';', ',' or ')' before numeric constant 4 | int func(int p, int q, double a, int n, int 1) | ^ main.c: In function 'main': main.c:30:24: error: implicit declaration of function 'unit'; did you mean 'unix'? [-Wimplicit-function-declaration] 30 | printf("%d\n", unit(p, q, (double)a, n, 1)); | ^~~~ | unix
s090088518
p00712
C
#include<stdio.h> #include<stdlib.h> int func(int p, int q, double a, int n, int l) { int i; int b=0; if(n>0&&p>0){ for(i=l;i<=a;i++){ if(p*i==q){ b++; } b+=func(p*i-q, q*i, a/i, n-1, i); } } return b; } int main(void) { int p, q, a, n; while(1) { scanf("%d %d %d %d ", &p, &q, &a, &n); if(p==0&&q==0&&a==0&&n==0) break; printf("%d\n", unit(p, q, (double)a, n, 1)); } return 0; }
main.c: In function 'main': main.c:30:24: error: implicit declaration of function 'unit'; did you mean 'unix'? [-Wimplicit-function-declaration] 30 | printf("%d\n", unit(p, q, (double)a, n, 1)); | ^~~~ | unix
s562131438
p00712
C
#include<stdio.h> #include<stdlib.h> int func(int p, int q, double a, int n, int l) { int i; int b=0; if(n>0&&p>0){ for(i=l;i<=a;i++){ if(p*i==q){ b++; } b+=func(p*i-q, q*i, a/i, n-1, i); } } return b; } int main(void) { int p, q, a, n; while(1) { scanf("%d %d %d %d ", &p, &q, &a, &n); if(p==0&&q==0&&a==0&&n==0) break; printf("%d\n", unit(p, q, (double)a, n, 1)); } return 0; }
main.c: In function 'main': main.c:30:24: error: implicit declaration of function 'unit'; did you mean 'unix'? [-Wimplicit-function-declaration] 30 | printf("%d\n", unit(p, q, (double)a, n, 1)); | ^~~~ | unix
s857042468
p00712
C
#include <iostream> #include <algorithm> using namespace std; int a, n, p, q; int gcd(int x, int y){ return (y == 0) ? x : gcd(y, x%y); } int lcm(int x, int y){ return x * y / gcd(x, y); } int solve(int sp, int sq, int sa, int sn, int pre){ if(sn > n) return 0; if(p / q < sp / sq) return 0; if(sp == p && sq == q) return 1; int res = 0; for(int i=pre;sa*i<=a;i++){ int tp = 1, tq = i; int tmp = lcm(sq, tq); tp = tp * (tmp / tq) + sp * (tmp / sq); tq = tmp; tmp = gcd(tp, tq); res += solve(tp/tmp, tq/tmp, sa*i, sn+1, i); } return res; } main(){ while(cin >> p >> q >> a >> n && (p|q|a|n)){ int tmp = gcd(p, q), ans = 0; p /= tmp; q /= tmp; for(int i=1;i<=a&&n>0;i++) ans += solve(1, i, i, 1, i); cout << ans << endl; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s436655150
p00712
C++
inline int solve(pair<int,int> fra, int b, int a, int n){ int res = 0, temp = 1, hoge; // cout<<fra.numerator<<"/"<<fra.denominator<<" "<<b<<" "<<a<<" "<<n<<endl; if(n == 0) return 0; if(n == 1){ if(fra.numerator == 1 && b <= fra.denominator && fra.denominator <= a) return 1; else return 0; } if(fra.numerator*b > fra.denominator*n) return -1; // cout<<"temp "<<temp<<endl; for(int i = 1;fra.numerator*b > fra.denominator*i; i++){ temp *= b; if(temp > a){ // con++; return 0; } } // cout<<"temp "<<temp<<endl; for(int i = max(b, fra.denominator/fra.numerator); i <= a; i++){ if(fra.numerator*i == fra.denominator) res++; else if(fra.numerator*i > fra.denominator){ hoge = solve(add(fra,make_pair(-1,i)),i,a/i,n-1); if(hoge == -1)break; res += hoge; } } return res; }
a.cc:1:18: error: 'pair' was not declared in this scope 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~~ a.cc:1:23: error: expected primary-expression before 'int' 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~ a.cc:1:27: error: expected primary-expression before 'int' 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~ a.cc:1:37: error: expected primary-expression before 'int' 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~ a.cc:1:44: error: expected primary-expression before 'int' 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~ a.cc:1:51: error: expected primary-expression before 'int' 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^~~ a.cc:1:56: error: expression list treated as compound expression in initializer [-fpermissive] 1 | inline int solve(pair<int,int> fra, int b, int a, int n){ | ^
s673673178
p00712
C++
#include<cstdio> int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int p,q,a,n; int cnt; void dfs(int v,int l,int r,int now){ if(v!=0){ int d=gcd(r,l); if((double)p/q<(double)l/r)return; if(l/d==p && r/d==q)cnt++; } if(v<n){ for(int i=now;i<=a/r;i++){ data[v]=i; dfs(v+1,l*i+r,r*i,i); } } } int main(void){ while(1){ scanf("%d %d %d %d",&p,&q,&a,&n); if(p+q+a+n==0)break; int d=gcd(p,q); p/=d; q/=d; cnt=0; dfs(0,0,1,1); printf("%d\n",cnt); } return 0; }
a.cc: In function 'void dfs(int, int, int, int)': a.cc:19:25: error: 'data' was not declared in this scope 19 | data[v]=i; | ^~~~
s711640280
p00712
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define fst first #define snd second #define MP make_pair #define PB push_back VI PS, QS, AS, NS, cnts; int P, Q, A, N; int T; VVI have_n_ts; // p / q PII ymemo[10000][10000] = {} int p_, q_; inline void yakubun(int p, int q) { p_ = p, q_ = q; if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { p = ymemo[p_][q_].fst; q = ymemo[p_][q_].snd; return; } int c = __gcd(p, q); if (c - 1) return; p /= c; q /= c; if (p_ < 10000 && q_ < 10000) { ymemo[p_][q_].fst = p; ymemo[p_][q_].snd = q; } } inline void add(int p1, int q1, int p2, int q2, int &np, int &nq) { np = p1 * q2 + p2 * q1; nq = q1 * q2; yakubun(np, nq); } inline void sub(int p1, int q1, int p2, int q2, int &np, int &nq) { add(p1, q1, -1 * p2, q2, np, nq); } inline void dfs(int p, int q, int a, int n, int before) { if (a > 12000) return; if (n >= 7) return; for (int t : have_n_ts[n]) { cnts[t] += a <= AS[t] && p == PS[t] && q == QS[t]; } int np, nq; if (n == 6) { for (int t : have_n_ts[7]) { if (AS[t] > a) continue; sub(PS[t], QS[t], p, q, np, nq); cnts[t] += np == 1 && nq * a <= AS[t]; } return; } for (int i = before; i * a <= 12000; i++) { add(p, q, 1, i, np, nq); dfs(np, nq, a * i, n + 1, i); } } int main(void) { have_n_ts.resize(8); T = 0; while (cin >> P >> Q >> A >> N, P) { yakubun(P, Q); PS.PB(P); QS.PB(Q); AS.PB(A); NS.PB(N); for (int i = 1; i <= N; i++) { have_n_ts[i].PB(T); } ++T; } cnts.resize(T); dfs(0, 1, 1, 0, 1); for (auto cnt : cnts) cout << cnt << endl; return 0; }
a.cc:23:1: error: expected ',' or ';' before 'int' 23 | int p_, q_; | ^~~ a.cc: In function 'void yakubun(int, int)': a.cc:26:5: error: 'p_' was not declared in this scope; did you mean 'p'? 26 | p_ = p, q_ = q; | ^~ | p a.cc:26:13: error: 'q_' was not declared in this scope; did you mean 'q'? 26 | p_ = p, q_ = q; | ^~ | q
s461033697
p00712
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<VI> VVI; #define fst first #define snd second #define MP make_pair #define PB push_back VI PS, QS, AS, NS, cnts; int P, Q, A, N; int T; VVI have_n_ts; // p / q PII ymemo[10000][10000] = {}; int p_, q_; inline void yakubun(int p, int q) { p_ = p, q_ = q; if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { p = ymemo[p_][q_].fst; q = ymemo[p_][q_].snd; return; } int c = __gcd(p, q); if (c - 1) return; p /= c; q /= c; if (p_ < 10000 && q_ < 10000) { ymemo[p_][q_].fst = p; ymemo[p_][q_].snd = q; } } inline void add(int p1, int q1, int p2, int q2, int &np, int &nq) { np = p1 * q2 + p2 * q1; nq = q1 * q2; yakubun(np, nq); } inline void sub(int p1, int q1, int p2, int q2, int &np, int &nq) { add(p1, q1, -1 * p2, q2, np, nq); } inline void dfs(int p, int q, int a, int n, int before) { if (a > 12000) return; if (n >= 7) return; for (int t : have_n_ts[n]) { cnts[t] += a <= AS[t] && p == PS[t] && q == QS[t]; } int np, nq; if (n == 6) { for (int t : have_n_ts[7]) { if (AS[t] > a) continue; sub(PS[t], QS[t], p, q, np, nq); cnts[t] += np == 1 && nq * a <= AS[t]; } return; } for (int i = before; i * a <= 12000; i++) { add(p, q, 1, i, np, nq); dfs(np, nq, a * i, n + 1, i); } } int main(void) { have_n_ts.resize(8); T = 0; while (cin >> P >> Q >> A >> N, P) { yakubun(P, Q); PS.PB(P); QS.PB(Q); AS.PB(A); NS.PB(N); for (int i = 1; i <= N; i++) { have_n_ts[i].PB(T); } ++T; } cnts.resize(T); dfs(0, 1, 1, 0, 1); for (auto cnt : cnts) cout << cnt << endl; return 0; }
a.cc: In function 'void yakubun(int, int)': a.cc:27:34: error: no match for 'operator&&' (operand types are 'bool' and 'PII' {aka 'std::pair<int, int>'}) 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ~~~~~~~~~~~~~~~~~~~~~~~~ ^~ ~~~~~~~~~~~~~ | | | | bool PII {aka std::pair<int, int>} a.cc:27:34: note: candidate: 'operator&&(bool, bool)' (built-in) 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~ a.cc:27:34: note: no known conversion for argument 2 from 'PII' {aka 'std::pair<int, int>'} to 'bool' In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:27:49: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:27:49: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:27:49: note: 'PII' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:27:49: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:27:49: note: 'PII' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const valarray<_Tp>&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:27:49: note: mismatched types 'const std::valarray<_Tp>' and 'bool' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:27:49: note: mismatched types 'const std::valarray<_Tp>' and 'bool' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:27:49: note: 'PII' {aka 'std::pair<int, int>'} is not derived from 'const std::valarray<_Tp>' 27 | if (p_ < 10000 && q_ < 10000 && ymemo[p_][q_]) { | ^
s347787196
p00712
C++
// Header {{{ // includes {{{ #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <sys/time.h> #include <unistd.h> #include <vector> // }}} using namespace std; // consts {{{ static const int INF = 1e9; static const double PI = acos(-1.0); static const double EPS = 1e-10; // }}} // typedefs {{{ typedef long long int LL; typedef unsigned long long int ULL; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<LL> VLL; typedef vector<VLL> VVLL; typedef vector<ULL> VULL; typedef vector<VULL> VVULL; typedef vector<double> VD; typedef vector<VD> VVD; typedef vector<bool> VB; typedef vector<VB> VVB; typedef vector<char> VC; typedef vector<VC> VVC; typedef vector<VVC> VVVC; typedef vector<string> VS; typedef vector<VS> VVS; typedef pair<int, int> PII; typedef complex<int> P; #define PQ(type) priority_queue<type> // priority queue reverse #define PQR(type) priority_queue< type, vector<type>, greater<type> > // }}} // macros & inline functions {{{ // syntax sugars {{{ #define FOR(i, b, e) for (typeof(e) i = (b); i < (e); ++i) #define FORI(i, b, e) for (typeof(e) i = (b); i <= (e); ++i) #define REP(i, n) FOR(i, 0, n) #define REPI(i, n) FORI(i, 0, n) #define OPOVER(_op, _type) inline bool operator _op (const _type &t) const #define ASSIGN_MAX(var, val) ((var) = max((var), (val))) #define ASSIGN_MIN(var, val) ((var) = min((var), (val))) // }}} // conversion {{{ inline int toInt(string s) { int v; istringstream sin(s); sin>>v; return v; } template<class T> inline string toString(T x) { ostringstream sout; sout<<x; return sout.str(); } // }}} // array and STL {{{ #define ARRSIZE(a) ( sizeof(a) / sizeof(a[0]) ) #define ZERO(a, v) ( assert(v == 0 || v == -1), memset(a, v, sizeof(a)) ) #define F first #define S second #define MP(a, b) make_pair(a, b) #define SIZE(a) ((LL)a.size()) #define PB(e) push_back(e) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EACH(c, it) for(typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define REACH(c, it) for(typeof((c).rbegin()) it=(c).rbegin(); it!=(c).rend(); ++it) #define EXIST(s, e) ((s).find(e) != (s).end()) // }}} // bit manipulation {{{ // singed integers are not for bitwise operations, specifically arithmetic shifts ('>>', and maybe not good for '<<' too) #define IS_UNSIGNED(n) (!numeric_limits<typeof(n)>::is_signed) #define BIT(n) (assert(IS_UNSIGNED(n)), assert(n < 64), (1ULL << (n))) #define BITOF(n, m) (assert(IS_UNSIGNED(n)), assert(m < 64), ((ULL)(n) >> (m) & 1)) inline int BITS_COUNT(ULL b) { int c = 0; while(b != 0) { c += (b & 1); b >>= 1; } return c; } inline int MSB(ULL b) { int c = 0; while(b != 0) { ++c; b >>= 1; } return c-1; } inline int MAKE_MASK(ULL upper, ULL lower) { assert(lower < 64 && upper < 64 && lower <= upper); return (BIT(upper) - 1) ^ (BIT(lower) - 1); } // }}} // for readable code {{{ #define EVEN(n) (n % 2 == 0) #define ODD(n) (!EVEN(n)) // }}} // debug {{{ #define arrsz(a) ( sizeof(a) / sizeof(a[0]) ) #define dprt(fmt, ...) if (opt_debug) { fprintf(stderr, fmt, ##__VA_ARGS__); } #define darr(a) if (opt_debug) { copy( (a), (a) + arrsz(a), ostream_iterator<int>(cerr, " ") ); cerr << endl; } #define darr_range(a, f, t) if (opt_debug) { copy( (a) + (f), (a) + (t), ostream_iterator<int>(cerr, " ") ); cerr << endl; } #define dvec(v) if (opt_debug) { copy( ALL(v), ostream_iterator<int>(cerr, " ") ); cerr << endl; } #define darr2(a) if (opt_debug) { FOR(__i, 0, (arrsz(a))){ darr( (a)[__i] ); } } #define WAIT() if (opt_debug) { string _wait_; cerr << "(hit return to continue)" << endl; getline(cin, _wait_); } #define dump(x) if (opt_debug) { cerr << " [L" << __LINE__ << "] " << #x << " = " << (x) << endl; } // dump vector elements in [s, e) #define dumpv(v, s, e) if (opt_debug) { cerr << " [L" << __LINE__ << "] " << #v << " = "; FOR(__i, s, e) { cerr << v[__i] << "\t"; } cerr << endl; } #define dumpl(x) if (opt_debug) { cerr << " [L" << __LINE__ << "] " << #x << endl << (x) << endl; } #define dumpf() if (opt_debug) { cerr << __PRETTY_FUNCTION__ << endl; } #define where() if (opt_debug) { cerr << __FILE__ << ": " << __PRETTY_FUNCTION__ << " [L: " << __LINE__ << "]" << endl; } #define dumpb(bit, digits) if (opt_debug) { cerr << " [L" << __LINE__ << "] " << #bit << " = "; for(int __i = digits - 1; __i >= 0; __i--) { cerr << static_cast<bool>(bit & (1 << __i)); if (__i % 4 == 0) { cerr << " "; } } cerr << endl; } // ostreams {{{ // complex template<typename T> ostream& operator<<(ostream& s, const complex<T>& d) {return s << "(" << d.real() << ", " << d.imag() << ")";} // pair template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << ", " << d.second << ")";} // vector template<typename T> ostream& operator<<(ostream& s, const vector<T>& d) { int len = d.size(); REP (i, len) { s << d[i]; if (i < len - 1) s << "\t"; } return s; } // 2 dimentional vector template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& d) { int len = d.size(); REP (i, len) { s << d[i] << endl; } return s; } // set template<typename T> ostream& operator<<(ostream& s, const set<T>& v) { s << "{ "; for (typeof(v.begin()) itr = v.begin(); itr != v.end(); ++itr) { if (itr != v.begin()) { s << ", "; } s << (*itr); } s << " }"; return s; } // map template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) { s << "{" << endl; for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr) { s << "\t" << (*itr).first << " : " << (*itr).second << endl; } s << "}" << endl; return s; } // }}} // }}} // }}} // time {{{ inline double now(){ struct timeval tv; gettimeofday(&tv, NULL); return (static_cast<double>(tv.tv_sec) + static_cast<double>(tv.tv_usec) * 1e-6); } // }}} // string manipulation {{{ inline VS split(string s, char delimiter) { VS v; string t; REP(i, s.length()) { if(s[i] == delimiter) v.PB(t), t = ""; else t += s[i]; } v.PB(t); return v; } inline string join(VS s, string j) { string t; REP(i, s.size()) { t += s[i] + j; } return t; } // }}} // geometry {{{ #define Y real() #define X imag() // }}} // 2 dimentional array {{{ enum { UP, RIGHT, DOWN, LEFT, UP_RIGHT, DOWN_RIGHT, DOWN_LEFT, UP_LEFT }; int dy4[] = { -1, 0, 1, 0 }; int dx4[] = { 0, 1, 0, -1 }; P dydx4[4] = { P(-1, 0), P(0, 1), P(1, 0), P(0, -1) }; P dydx8[8] = { P(-1, 0), P(0, 1), P(1, 0), P(0, -1), P(-1, 1), P(1, 1), P(1, -1), P(-1, -1) }; bool in_field(int H, int W, P p) { return (0 <= p.Y && p.Y < H) && (0 <= p.X && p.X < W); } // }}} // input and output {{{ inline void input(string filename) { freopen(filename.c_str(), "r", stdin); } inline void output(string filename) { freopen(filename.c_str(), "w", stdout); } // }}} // }}} // Header under development {{{ template<typename T> T GCD(T a, T b) { return b == 0 ? a : GCD(b, a % b); } template<typename T> T LCM(T a, T b) { return a * b / GCD(a, b); } // Fraction class {{{ // ref: http://martin-thoma.com/fractions-in-cpp/ class Fraction { public: LL numerator; LL denominator; Fraction(LL _numerator, LL _denominator) { assert(_denominator > 0); numerator = _numerator; denominator = _denominator; if (denominator < 0) { denominator *= -1; numerator *= -1; } if (numerator == 0) { denominator = 1; } }; void reduce() { LL gcd = GCD(numerator, denominator); numerator /= gcd; denominator /= gcd; } }; typedef pair<Fraction, Fraction> PFF; PFF commonize_denominators(const Fraction& lhs, const Fraction& rhs) { LL lcm = LCM(lhs.denominator, rhs.denominator); Fraction a(lhs.numerator * lcm / lhs.denominator, lcm); Fraction b(rhs.numerator * lcm / rhs.denominator, lcm); return MP(a, b); } Fraction operator+(const Fraction& lhs, const Fraction& rhs) { PFF p = commonize_denominators(lhs, rhs); Fraction a = p.F, b = p.S; return Fraction(a.numerator + b.numerator, a.denominator); } Fraction operator-(const Fraction& lhs, const Fraction& rhs) { PFF p = commonize_denominators(lhs, rhs); Fraction a = p.F, b = p.S; return Fraction(a.numerator - b.numerator, a.denominator); } Fraction operator*(const Fraction& lhs, const Fraction& rhs) { return Fraction(lhs.numerator * rhs.numerator, lhs.denominator * rhs.denominator); } Fraction operator/(const Fraction& lhs, const Fraction& rhs) { return Fraction(lhs.numerator * rhs.denominator, lhs.denominator * rhs.numerator); } bool operator<(const Fraction& lhs, const Fraction& rhs) { PFF p = commonize_denominators(lhs, rhs); Fraction a = p.F, b = p.S; return a.numerator < b.numerator; } template<typename T> bool operator<(const Fraction& lhs, const T rhs) { return lhs < Fraction(rhs, 1); } bool operator>(const Fraction& lhs, const Fraction& rhs) { PFF p = commonize_denominators(lhs, rhs); Fraction a = p.F, b = p.S; return a.numerator > b.numerator; } template<typename T> bool operator>(const Fraction& lhs, const T rhs) { return lhs > Fraction(rhs, 1); } bool operator==(const Fraction& lhs, const Fraction& rhs) { return !(lhs < rhs) && !(lhs > rhs); } template<typename T> bool operator==(const Fraction& lhs, const T rhs) { return lhs == Fraction(rhs, 1); } std::ostream& operator<<(std::ostream &s, const Fraction &a) { if (a.denominator == 1) { s << a.numerator; } else { s << a.numerator << "/" << a.denominator; } return s; } // }}} // }}} bool opt_debug = false; int p, q, a, n; int solve(Fraction frac, int start, int ca, int cn, vector<Fraction> fracs) { dump(frac); if (frac == 0) { dump(fracs); return 1; } if (ca >= a) { return 0; } if (cn <= 0) { return 0; } if (start > ca) { return 0; } if (frac > Fraction(1 / start) * cn) { return 0; } int ret = 0; for (int denom = start; denom <= a / ca; ++denom) { Fraction unit(1, denom); Fraction remain = frac - unit; if (remain < 0) { continue; } vector<Fraction> nfracs = fracs; nfracs.PB(unit); ret += solve(remain, denom, ca * denom, cn - 1, nfracs); } return ret; } int main(int argc, char** argv) { std::ios_base::sync_with_stdio(false); // set options {{{ int __c; while ( (__c = getopt(argc, argv, "d")) != -1 ) { switch (__c) { case 'd': opt_debug = true; break; default: abort(); } } // }}} // opt_debug = true; // input("./inputs/1"); // output("./outputs/0"); while(cin >> p >> q >> a >> n, p) { cout << solve(Fraction(p, q), 1, 1, n, vector<Fraction>()) << endl; } return 0; } // vim: foldmethod=marker
a.cc: In function 'int solve(Fraction, int, int, int, std::vector<Fraction>)': a.cc:322:38: error: no matching function for call to 'Fraction::Fraction(int)' 322 | if (frac > Fraction(1 / start) * cn) { return 0; } | ^ a.cc:215:17: note: candidate: 'Fraction::Fraction(LL, LL)' 215 | Fraction(LL _numerator, LL _denominator) { | ^~~~~~~~ a.cc:215:17: note: candidate expects 2 arguments, 1 provided a.cc:211:7: note: candidate: 'constexpr Fraction::Fraction(const Fraction&)' 211 | class Fraction { | ^~~~~~~~ a.cc:211:7: note: no known conversion for argument 1 from 'int' to 'const Fraction&' a.cc:211:7: note: candidate: 'constexpr Fraction::Fraction(Fraction&&)' a.cc:211:7: note: no known conversion for argument 1 from 'int' to 'Fraction&&'
s610549436
p00712
C++
#include <iostream> using namespace std; void func(int,int,double,int); int p,q,a,n,cnt; double k; int main(){ while(1){ cin>>p>>q>>a>>n; if(!p&&!q&&!a&&!n) break; k=1.0*p/q; cnt=0; func(0,1,0,1); cout<<cnt<<endl; } return 0; } void func(int x,int w,double y,int I){ if(-0.00000001<=k-y&&k-y<=0.00000001) cnt++; if(x==n) return ; for(int i=I;w*i<=a;i++){ if(y+1.0/i>k+0.5) continue; func(x+1,w*i,1.0/i+y,i); } } #include <iostream> using namespace std; void func(int,int,double,int); int p,q,a,n,cnt; double k; int main(){ while(1){ cin>>p>>q>>a>>n; if(!p&&!q&&!a&&!n) break; k=1.0*p/q; cnt=0; func(0,1,0,1); cout<<cnt<<endl; } return 0; } void func(int x,int w,double y,int I){ if(-0.00000001<=k-y&&k-y<=0.00000001) cnt++; if(x==n) return ; for(int i=I;w*i<=a;i++){ if(y+1.0/i>k+0.5) continue; func(x+1,w*i,1.0/i+y,i); } }
a.cc:30:5: error: redefinition of 'int p' 30 | int p,q,a,n,cnt; | ^ a.cc:4:5: note: 'int p' previously declared here 4 | int p,q,a,n,cnt; | ^ a.cc:30:7: error: redefinition of 'int q' 30 | int p,q,a,n,cnt; | ^ a.cc:4:7: note: 'int q' previously declared here 4 | int p,q,a,n,cnt; | ^ a.cc:30:9: error: redefinition of 'int a' 30 | int p,q,a,n,cnt; | ^ a.cc:4:9: note: 'int a' previously declared here 4 | int p,q,a,n,cnt; | ^ a.cc:30:11: error: redefinition of 'int n' 30 | int p,q,a,n,cnt; | ^ a.cc:4:11: note: 'int n' previously declared here 4 | int p,q,a,n,cnt; | ^ a.cc:30:13: error: redefinition of 'int cnt' 30 | int p,q,a,n,cnt; | ^~~ a.cc:4:13: note: 'int cnt' previously declared here 4 | int p,q,a,n,cnt; | ^~~ a.cc:31:8: error: redefinition of 'double k' 31 | double k; | ^ a.cc:5:8: note: 'double k' previously declared here 5 | double k; | ^ a.cc:33:5: error: redefinition of 'int main()' 33 | int main(){ | ^~~~ a.cc:7:5: note: 'int main()' previously defined here 7 | int main(){ | ^~~~ a.cc:45:6: error: redefinition of 'void func(int, int, double, int)' 45 | void func(int x,int w,double y,int I){ | ^~~~ a.cc:19:6: note: 'void func(int, int, double, int)' previously defined here 19 | void func(int x,int w,double y,int I){ | ^~~~
s958734204
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction(Type p_, Type q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:16:18: error: declaration of template parameter 'Type' shadows template parameter 16 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:17:18: error: declaration of template parameter 'Type' shadows template parameter 17 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p < 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p > 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p <= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p >= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc: In function 'bool operator<(const Fraction<Type>&, const Fraction<Type>&)': a.cc:22:125: error: expected primary-expression before 'f3' 22 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p < 0; } | ^~ a.cc:22:125: error: expected ';' before 'f3' a.cc:22:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 22 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type>&, const Fraction<Type>&)': a.cc:23:125: error: expected primary-expression before 'f3' 23 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p > 0; } | ^~ a.cc:23:125: error: expected ';' before 'f3' a.cc:23:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 23 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:24:126: error: expected primary-expression before 'f3' 24 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p <= 0; } | ^~ a.cc:24:126: error: expected ';' before 'f3' a.cc:24:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:25:126: error: expected primary-expression before 'f3' 25 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p >= 0; } | ^~ a.cc:25:126: error: expected ';' before 'f3' a.cc:25:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f1.p >= 0; } | ^~ | f1 a.cc: At global scope: a.cc:31:15: error: no matching function for call to 'Fraction<int>::Fraction()' 31 | Fraction<int> f; int p, q, a, n; | ^ a.cc:14:9: note: candidate: 'Fraction<Type>::Fraction(Type, Type) [with Type = int]' 14 | Fraction(Type p_, Type q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q <
s268665283
p00712
C++
#include <cmath> #include <cstdio> template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(Type p_, Type q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:16:18: error: declaration of template parameter 'Type' shadows template parameter 16 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:17:18: error: declaration of template parameter 'Type' shadows template parameter 17 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:8:10: note: template parameter 'Type' declared here 8 | template<typename Type> class Fraction { | ^~~~~~~~
s152703286
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction<Type>() : p(0), q(1) {} Fraction<Type>(Type p_, Type q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:17:18: error: declaration of template parameter 'Type' shadows template parameter 17 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:30:18: error: declaration of template parameter 'Type' shadows template parameter 30 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~
s522208300
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction<Type> { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction<Type>() : p(0), q(1) {} Fraction<Type>(Type p_, Type q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:9:31: error: 'Fraction' is not a class template 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:17:14: error: declaration of template parameter 'Type' shadows template parameter 17 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p == f2.p && f1.q == f2.q; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:18:14: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1.p != f2.p || f1.q != f2.q; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:19:14: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:20:14: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:21:14: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:22:14: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:23:14: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:24:14: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:25:14: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:26:14: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:27:14: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:28:14: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:29:14: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~ a.cc:30:14: error: declaration of template parameter 'Type' shadows template parameter 30 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction<Type> { | ^~~~~~~~
s564735219
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type> f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:16:9: error: invalid constructor; you probably meant 'Fraction<Type> (const Fraction<Type>&)' 16 | Fraction(const Fraction<Type> f) : p(f.p), q(f.q) {} | ^~~~~~~~ a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:30:18: error: declaration of template parameter 'Type' shadows template parameter 30 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:31:18: error: declaration of template parameter 'Type' shadows template parameter 31 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc: In function 'bool operator<(const Fraction<Type>&, const Fraction<Type>&)': a.cc:24:125: error: expected primary-expression before 'f3' 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ a.cc:24:125: error: expected ';' before 'f3' a.cc:24:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type>&, const Fraction<Type>&)': a.cc:25:125: error: expected primary-expression before 'f3' 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ a.cc:25:125: error: expected ';' before 'f3' a.cc:25:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:26:126: error: expected primary-expression before 'f3' 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ a.cc:26:126: error: expected ';' before 'f3' a.cc:26:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:27:126: error: expected primary-expression before 'f3' 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ a.cc:27:126: error: expected ';' before 'f3' a.cc:27:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ | f1
s204377613
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<typename Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type>& f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<typename Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<typename Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<typename Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<typename Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<typename Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<typename Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<typename Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<typename Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:30:18: error: declaration of template parameter 'Type' shadows template parameter 30 | template<typename Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc:31:18: error: declaration of template parameter 'Type' shadows template parameter 31 | template<typename Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<typename Type> class Fraction { | ^~~~~~~~ a.cc: In function 'bool operator<(const Fraction<Type>&, const Fraction<Type>&)': a.cc:24:125: error: expected primary-expression before 'f3' 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ a.cc:24:125: error: expected ';' before 'f3' a.cc:24:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<typename Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type>&, const Fraction<Type>&)': a.cc:25:125: error: expected primary-expression before 'f3' 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ a.cc:25:125: error: expected ';' before 'f3' a.cc:25:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<typename Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:26:126: error: expected primary-expression before 'f3' 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ a.cc:26:126: error: expected ';' before 'f3' a.cc:26:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 26 | template<typename Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:27:126: error: expected primary-expression before 'f3' 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ a.cc:27:126: error: expected ';' before 'f3' a.cc:27:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 27 | template<typename Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ | f1
s015261821
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<class Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type>& f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<class Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } template<class Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } template<class Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } template<class Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<class Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<class Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<class Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<class Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<class Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<class Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<class Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<class Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:30:18: error: declaration of template parameter 'Type' shadows template parameter 30 | template<class Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:31:18: error: declaration of template parameter 'Type' shadows template parameter 31 | template<class Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc: In function 'bool operator<(const Fraction<Type>&, const Fraction<Type>&)': a.cc:24:122: error: expected primary-expression before 'f3' 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ a.cc:24:122: error: expected ';' before 'f3' a.cc:24:122: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type>&, const Fraction<Type>&)': a.cc:25:122: error: expected primary-expression before 'f3' 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ a.cc:25:122: error: expected ';' before 'f3' a.cc:25:122: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:26:123: error: expected primary-expression before 'f3' 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ a.cc:26:123: error: expected ';' before 'f3' a.cc:26:123: error: 'f3' was not declared in this scope; did you mean 'f1'? 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:27:123: error: expected primary-expression before 'f3' 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ a.cc:27:123: error: expected ';' before 'f3' a.cc:27:123: error: 'f3' was not declared in this scope; did you mean 'f1'? 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ | f1
s069450947
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<class Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type>& f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<class Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } template<class Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } template<class Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<class Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } template<class Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc:18:18: error: declaration of template parameter 'Type' shadows template parameter 18 | template<class Type> friend bool operator==(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 == f2; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:19:18: error: declaration of template parameter 'Type' shadows template parameter 19 | template<class Type> friend bool operator!=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return f1 != f2; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:20:18: error: declaration of template parameter 'Type' shadows template parameter 20 | template<class Type> friend Fraction operator+(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:21:18: error: declaration of template parameter 'Type' shadows template parameter 21 | template<class Type> friend Fraction operator-(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:22:18: error: declaration of template parameter 'Type' shadows template parameter 22 | template<class Type> friend Fraction operator*(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:23:18: error: declaration of template parameter 'Type' shadows template parameter 23 | template<class Type> friend Fraction operator/(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:24:18: error: declaration of template parameter 'Type' shadows template parameter 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:25:18: error: declaration of template parameter 'Type' shadows template parameter 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:26:18: error: declaration of template parameter 'Type' shadows template parameter 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:27:18: error: declaration of template parameter 'Type' shadows template parameter 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:28:18: error: declaration of template parameter 'Type' shadows template parameter 28 | template<class Type> Fraction& operator+=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:29:18: error: declaration of template parameter 'Type' shadows template parameter 29 | template<class Type> Fraction& operator-=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:30:18: error: declaration of template parameter 'Type' shadows template parameter 30 | template<class Type> Fraction& operator*=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc:31:18: error: declaration of template parameter 'Type' shadows template parameter 31 | template<class Type> Fraction& operator/=(const Fraction<Type>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } | ^~~~~ a.cc:9:10: note: template parameter 'Type' declared here 9 | template<class Type> class Fraction { | ^~~~~ a.cc: In function 'bool operator<(const Fraction<Type>&, const Fraction<Type>&)': a.cc:24:122: error: expected primary-expression before 'f3' 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ a.cc:24:122: error: expected ';' before 'f3' a.cc:24:122: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<class Type> friend bool operator<(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type>&, const Fraction<Type>&)': a.cc:25:122: error: expected primary-expression before 'f3' 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ a.cc:25:122: error: expected ';' before 'f3' a.cc:25:122: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<class Type> friend bool operator>(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:26:123: error: expected primary-expression before 'f3' 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ a.cc:26:123: error: expected ';' before 'f3' a.cc:26:123: error: 'f3' was not declared in this scope; did you mean 'f1'? 26 | template<class Type> friend bool operator<=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type>&, const Fraction<Type>&)': a.cc:27:123: error: expected primary-expression before 'f3' 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ a.cc:27:123: error: expected ';' before 'f3' a.cc:27:123: error: 'f3' was not declared in this scope; did you mean 'f1'? 27 | template<class Type> friend bool operator>=(const Fraction<Type>& f1, const Fraction<Type>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ | f1
s678323411
p00712
C++
#include <cmath> #include <cstdio> template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<class Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs(p_), abs(q_))), q(q_ / gcd(abs(p_), abs(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type>& f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<class Type2> friend bool operator==(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return f1 == f2; } template<class Type2> friend bool operator!=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return f1 != f2; } template<class Type2> friend Fraction operator+(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator-(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator*(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator/(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<class Type2> friend bool operator<(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } template<class Type2> friend bool operator>(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } template<class Type2> friend bool operator<=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } template<class Type2> friend bool operator>=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } template<class Type2> Fraction& operator+=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator-=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator*=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator/=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc: In function 'bool operator<(const Fraction<Type2>&, const Fraction<Type2>&)': a.cc:23:125: error: expected primary-expression before 'f3' 23 | template<class Type2> friend bool operator<(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ a.cc:23:125: error: expected ';' before 'f3' a.cc:23:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 23 | template<class Type2> friend bool operator<(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p < 0; } | ^~ | f1 a.cc: In function 'bool operator>(const Fraction<Type2>&, const Fraction<Type2>&)': a.cc:24:125: error: expected primary-expression before 'f3' 24 | template<class Type2> friend bool operator>(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ a.cc:24:125: error: expected ';' before 'f3' a.cc:24:125: error: 'f3' was not declared in this scope; did you mean 'f1'? 24 | template<class Type2> friend bool operator>(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p > 0; } | ^~ | f1 a.cc: In function 'bool operator<=(const Fraction<Type2>&, const Fraction<Type2>&)': a.cc:25:126: error: expected primary-expression before 'f3' 25 | template<class Type2> friend bool operator<=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ a.cc:25:126: error: expected ';' before 'f3' a.cc:25:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 25 | template<class Type2> friend bool operator<=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p <= 0; } | ^~ | f1 a.cc: In function 'bool operator>=(const Fraction<Type2>&, const Fraction<Type2>&)': a.cc:26:126: error: expected primary-expression before 'f3' 26 | template<class Type2> friend bool operator>=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ a.cc:26:126: error: expected ';' before 'f3' a.cc:26:126: error: 'f3' was not declared in this scope; did you mean 'f1'? 26 | template<class Type2> friend bool operator>=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction f3 = f1 - f2; return f3.p >= 0; } | ^~ | f1
s709265090
p00712
C++
#include <cmath> #include <cstdio> #pragma warning(disable : 4996) using namespace std; template<typename Type> Type gcd(Type a, Type b) { if (b == 0) return a; return gcd(b, a % b); } // ----- Fraction Class ------ // template<class Type> class Fraction { public: // ------ Variable ------ // Type p, q; // ------ Constructor ------ // Fraction() : p(0), q(1) {} Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs<Type>(p_), abs<Type>(q_))), q(q_ / gcd(abs<Type>(p_), abs<Type>(q_))) { if (q < 0) p = -p, q = -q; } Fraction(const Fraction<Type>& f) : p(f.p), q(f.q) {} // ------ Operator ------ // template<class Type2> friend bool operator==(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return f1 == f2; } template<class Type2> friend bool operator!=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return f1 != f2; } template<class Type2> friend Fraction operator+(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q + f1.q * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator-(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q - f1.q * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator*(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.p, f1.q * f2.q); } template<class Type2> friend Fraction operator/(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { return Fraction(f1.p * f2.q, f1.q * f2.p); } template<class Type2> friend bool operator<(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { Fraction f3 = f1 - f2; return f3.p < 0; } template<class Type2> friend bool operator>(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { Fraction f3 = f1 - f2; return f3.p > 0; } template<class Type2> friend bool operator<=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { Fraction f3 = f1 - f2; return f3.p <= 0; } template<class Type2> friend bool operator>=(const Fraction<Type2>& f1, const Fraction<Type2>& f2) { Fraction f3 = f1 - f2; return f3.p >= 0; } template<class Type2> Fraction& operator+=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q + q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator-=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q - q * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator*=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.p, q * f1.q); p = f2.p; q = f2.q; return *this; } template<class Type2> Fraction& operator/=(const Fraction<Type2>& f1) { Fraction f2 = Fraction(p * f1.q, q * f1.p); p = f2.p; q = f2.q; return *this; } }; Fraction<int> f; int p, q, a, n; int solve(Fraction<int> f1, int a1, int c, int d) { if (f1 > f) return 0; if (f1 == f) return 1; if (d >= n) return 0; int ret = 0; for (int i = c; a1 * i <= a; i++) { ret += solve(f1 + Fraction<int>(1, i), a1 * i, i, d + 1); } return ret; } int main() { while (~scanf("%d%d%d%d", &p, &q, &a, &n)) { if (p == 0 && q == 0 && a == 0 && n == 0) break; f = Fraction<int>(p, q); printf("%d\n", solve(Fraction<int>(0, 1), 1, 1, 0)); } return 0; }
a.cc: In constructor 'Fraction<Type>::Fraction(const Type&, const Type&)': a.cc:16:71: error: expected primary-expression before '>' token 16 | Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs<Type>(p_), abs<Type>(q_))), q(q_ / gcd(abs<Type>(p_), abs<Type>(q_))) { if (q < 0) p = -p, q = -q; } | ^ a.cc:16:86: error: expected primary-expression before '>' token 16 | Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs<Type>(p_), abs<Type>(q_))), q(q_ / gcd(abs<Type>(p_), abs<Type>(q_))) { if (q < 0) p = -p, q = -q; } | ^ a.cc:16:114: error: expected primary-expression before '>' token 16 | Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs<Type>(p_), abs<Type>(q_))), q(q_ / gcd(abs<Type>(p_), abs<Type>(q_))) { if (q < 0) p = -p, q = -q; } | ^ a.cc:16:129: error: expected primary-expression before '>' token 16 | Fraction(const Type& p_, const Type& q_) : p(p_ / gcd(abs<Type>(p_), abs<Type>(q_))), q(q_ / gcd(abs<Type>(p_), abs<Type>(q_))) { if (q < 0) p = -p, q = -q; } | ^
s280312292
p00712
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<double,pa> #define ppa pair<string,int> #define ppap pair<int,pa> #define ssa pair<string,int> #define mp make_pair #define pb push_back #define EPS (1e-12) #define equals(a,b) (fabs((a)-(b))<EPS) #define VI vector<int> using namespace std; class pas{ public: int x,y; pas(int x=0,int y=0):x(x),y(y) {} pas operator + (pas p) {return pas(x+p.x,y+p.y);} pas operator - (pas p) {return pas(x-p.x,y-p.y);} pas operator * (int a) {return pas(x*a,y*a);} pas operator / (int a) {return pas(x/a,y/a);} // double absv() {return sqrt(norm());} int norm() {return x*x+y*y;} bool operator < (const pas &p) const{ return x != p.x ? x<p.x: y<p.y; } // bool operator < (const pas &p) const{ // return y != p.y ? y<p.y: x<p.x; // } bool operator == (const pas &p) const{ return x==p.x && y==p.y; } }; class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; #define pl pair<int,pas> struct Segment{ Point p1,p2; }; struct star{ Segment se[5]; }; double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } bool parareru(Point a,Point b,Point c,Point d){ // if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl; return abs(cross(a-b,d-c))<EPS; } double distance_ls_p(Point a, Point b, Point c) { if ( dot(b-a, c-a) < EPS ) return (c-a).absv(); if ( dot(a-b, c-b) < EPS ) return (c-b).absv(); return abs(cross(b-a, c-a)) / (b-a).absv(); } bool is_intersected_ls(Segment a,Segment b) { if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false; if(parareru((a.p2),(a.p1),(b.p1),(b.p2))&&parareru((a.p2),(a.p1),(b.p1),(b.p1))){ // cout<<"sss"<<endl; if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true; if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true; if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true; if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true; return false; } else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS ); } double segment_len(Segment a){ return (a.p1-a.p2).absv(); } double segment_dis(Segment a,Segment b){ if(is_intersected_ls(a,b))return 0; double r=distance_ls_p(a.p1, a.p2, b.p1); r=min(r,distance_ls_p(a.p1, a.p2, b.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2-b.p1; double d1 = abs(cross(ba, a.p1-b.p1)); double d2 = abs(cross(ba, a.p2-b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2-a.p1) * t; } pair<Point,Point> circle_intersection(Point c1,double r1,Point c2,double r2){ double d=(c1-c2).absv(); double h=(r1*r1-r2*r2+d*d)/2.0/d; double l=sqrt(r1*r1-h*h); // cout<<d<<" "<<h<<" "<<l<<endl; Point asi=c1+(c2-c1)*h/((c2-c1).absv()); Vector r1r2=(c2-c1)/((c2-c1).absv()); Vector sui={r1r2.y,-r1r2.x}; // cout<<sui.x<<" "<<sui.y<<endl; pair<Point,Point> z=mp(asi+sui*l,asi-sui*l); if(z.first.x>z.second.x) swap(z.first,z.second); return z; } int gcd(int x,int y){ if(x<y) return gcd(y,x); if(x==y) return x; if(x%y==0) return y; return gcd(y,x%y); } class pa2{ public: int x,y; pa2(int x=0,int y=0):x(x),y(y) {} pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);} pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);} bool operator < (const pa2 &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator > (const pa2 &p) const{ return x != p.x ? x>p.x: y>p.y; } bool operator == (const pa2 &p) const{ return abs(x-p.x)==0 && abs(y-p.y)==0; } bool operator != (const pa2 &p) const{ return !(abs(x-p.x)==0 && abs(y-p.y)==0); } }; /*   ---memo--- add_edge(始点,終点,youryou ,コスト)で枝追加 min_cost_flow(始点,終点,ryou)でhiyouをintで返す */ int p,q,ans,a,n; pa bun(int si1,int bo1,int si2,int bo2){ int g=gcd(bo1,bo2); int bo3=bo1*bo2/g; si3=si1*bo2/g+si2*bo1/g; g=gcd(so3,bo3); return mp(so3/g,bo3/g); } void dfs(int si,int bo,int seki,int kosuu,int saigo){ if(p*bo==si*q){ ans++; return; } if(p*bo<si*q) return; if(kosuu==n) return; //cout<<si<<" "<<bo<<" "<<seki<<" "<<kosuu<<" "<<saigo<<endl; for(int i=saigo;i*seki<=a;i++){ // cout<<i<<endl; pa z=bun(si,bo,n-kosuu,i); if(z.second*p>z.first*q) return; int g=gcd(bo,i); int s2=bo/g; int bo2=bo*(i/g); int si2=si*(i/g)+s2; g=gcd(si2,bo2); if(g>1){ si2/=g; bo2/=g; } dfs(si2,bo2,i*seki,kosuu+1,i); } } signed main(){ while(1){ cin>>p>>q>>a>>n; if(p==0 && q==0) return 0; ans=0; dfs(0,1,1,0,1); cout<<ans<<endl; } return 0; }
a.cc: In function 'std::pair<long long int, long long int> bun(long long int, long long int, long long int, long long int)': a.cc:174:9: error: 'si3' was not declared in this scope; did you mean 'si1'? 174 | si3=si1*bo2/g+si2*bo1/g; | ^~~ | si1 a.cc:175:15: error: 'so3' was not declared in this scope; did you mean 'bo3'? 175 | g=gcd(so3,bo3); | ^~~ | bo3
s486200434
p00712
C++
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> using namespace std; void yakubun(int &p,int &q){ for(int i = 2; i <= q; i++){ if(p%i==0&&q%i==0){ p/=i; q/=i; i--; } } } int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b); } int lcm(int a,int b){ return a*b/gcd(a,b); } // ツ暗クツつォツ算ツづーツ行ツつ、 void subOperation(int p,int q,int r,int s,int &np,int &nq){ int t=lcm(s,q); int u=(t/q)*p-(t/s)*r; yakubun(u,t); np=u;nq=t; } #define EPS (1e-10) int lim; int cnt; void dfs(int p,int q,int next,int rem,int a){ if(a>lim) return; else{ if(p==1) if(a*q<=lim&&q>=next) cnt++; rem--; if(rem==0) return; for(int i = (int)(sqrt(1.0*lim/a)+EPS); i >= next; i--){ //if(i*i*a>lim)continue; int np,nq; subOperation(p,q,1,i,np,nq); if(np<=0) break; if(i*a*nq<=lim) dfs(np,nq,i,rem,i*a); } } } int main(){ int p,q,a,n; while(cin>>p>>q>>a>>n&&!(p==0&&q==0&&a==0&&n==0)){ lim=a;cnt=0; yakubun(p,q); // ツ催渉可づ個青板つゥツづァツづづアツづづアツ暗クツつ「ツづつ「ツつュツ催帰 dfs(p,q,1,n,1); cout<<cnt<<endl; } return 0; }
a.cc: In function 'void dfs(int, int, int, int, int)': a.cc:47:27: error: 'sqrt' was not declared in this scope 47 | for(int i = (int)(sqrt(1.0*lim/a)+EPS); i >= next; i--){ | ^~~~
s908755949
p00712
C++
#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<queue> using namespace std; #define reps(i,f,n) for(int i=f;i<int(n);i++) #define rep(i,n) reps(i,0,n) int cont; void saiki(double rest,int a, int n, int st, vector<int>& bin){ if(fabs(rest)<0.0000001){cont++; return;} if(bin.size()==n)return; int sum = 1; rep(i,bin.size())sum*=bin[i]; for(int i=st;;i++){ if(sum*i<=a){ bin.push_back(i); saiki(rest-1.0/i, a, n, i, bin); bin.pop_back(); }else{ break; } } } int main(){ while(1){ int p,q,a,n; cin>>p>>q>>a>>n; cont = 0; if(n==0)break; vector<int> bin; int st = 1; double rest = (double)p/q; saiki(rest,a,n,st,bin); printf("%d\n",cont); } }
a.cc: In function 'void saiki(double, int, int, int, std::vector<int>&)': a.cc:17:12: error: 'fabs' was not declared in this scope; did you mean 'labs'? 17 | if(fabs(rest)<0.0000001){cont++; return;} | ^~~~ | labs
s849795374
p00712
C++
#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<queue> #include<cstdlib> using namespace std; #define reps(i,f,n) for(int i=f;i<int(n);i++) #define rep(i,n) reps(i,0,n) int cont; void saiki(double rest,int a, int n, int st, vector<int>& bin){ if(fabs(rest)<0.0000001){cont++; return;} if(bin.size()==n)return; int sum = 1; rep(i,bin.size())sum*=bin[i]; for(int i=st;;i++){ if(sum*i<=a){ bin.push_back(i); saiki(rest-1.0/i, a, n, i, bin); bin.pop_back(); }else{ break; } } } int main(){ while(1){ int p,q,a,n; cin>>p>>q>>a>>n; cont = 0; if(n==0)break; vector<int> bin; int st = 1; double rest = (double)p/q; saiki(rest,a,n,st,bin); printf("%d\n",cont); } }
a.cc: In function 'void saiki(double, int, int, int, std::vector<int>&)': a.cc:18:12: error: 'fabs' was not declared in this scope; did you mean 'labs'? 18 | if(fabs(rest)<0.0000001){cont++; return;} | ^~~~ | labs
s301589237
p00712
C++
#include<cstdio> #include<iostream> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<queue> #include<cstdlib> #include<cmath> using namespace std; #define reps(i,f,n) for(int i=f;i<int(n);i++) #define rep(i,n) reps(i,0,n) int cont; void saiki(double rest,int a, int n, int st, vector<int>& bin){ if(fabs(rest)<0.0000001){cont++; return;} if(bin.size()==n)return; if(rest<0)break; int sum = 1; rep(i,bin.size())sum*=bin[i]; for(int i=st;;i++){ if(sum*i<=a){ bin.push_back(i); saiki(rest-1.0/i, a, n, i, bin); bin.pop_back(); }else{ break; } } } int main(){ while(1){ int p,q,a,n; cin>>p>>q>>a>>n; cont = 0; if(n==0)break; vector<int> bin; int st = 1; double rest = (double)p/q; saiki(rest,a,n,st,bin); printf("%d\n",cont); } }
a.cc: In function 'void saiki(double, int, int, int, std::vector<int>&)': a.cc:21:19: error: break statement not within loop or switch 21 | if(rest<0)break; | ^~~~~
s950661562
p00712
C++
#include <iostream> using namespace std; int P, Q, MS, C; bool f(int shi, int bo, int start, int dep, int check){ //cout << "!" << endl; //cout << shi << " " << bo << endl; if(check > MS) { return false; } if(shi * Q == bo * P) { Count++; //return true; } if(shi * Q > bo * P) { return false; } if(dep == 0) { return false; } for(int i = start; i <= 6000; i++) { f(i*shi + bo, bo*i, i, dep - 1, check * i); } return true; } int main(){ int n; while(cin >> P >> Q >> MS >> n) { if(P == 0 && Q == 0 && MS == 0 && n == 0) break; Count = 0; f(0, 1, 1, n, 1); cout << Count << endl; } return 0; }
a.cc: In function 'bool f(int, int, int, int, int)': a.cc:15:5: error: 'Count' was not declared in this scope 15 | Count++; | ^~~~~ a.cc: In function 'int main()': a.cc:41:5: error: 'Count' was not declared in this scope 41 | Count = 0; | ^~~~~
s140187879
p00712
C++
#include <complex> #include <sstream> #include <string> #include <algorithm> #include <deque> #include <list> #include <map> #include <numeric> #include <queue> #include <vector> #include <set> #include <limits> #include <cstdio> #include <cctype> #include <cmath> #include <cstdlib> #include <ctime> using namespace std; #define REP(i, j) for(int i = 0; i < j; ++i) #define FOR(i, j, k) for(int i = j; i < k; ++i) #define P pair<int, int> int ans = 0, p, q, a, n; void reduce(int &p, int &q, int &x, int &y){ p = p * y; x = x * q; q = q * y; y = q; } bool isSame(int x, int y){ // 求める分数とx, yで通分 int tmp_p = p, tmp_q = q; reduce(tmp_p, tmp_q, x, y); // 値が同じならok if(tmp_p == x){ return true; } else{ // 違うならだめ return false; } } // 必要なもの ... 今までの和の分子、分母、何個見たか、どの数まで見たか // 必ず通分すれば積は求めなくていい // 答えを求めるときも通分する void dfs(int x, int y, int cnt, int max){ // それが答えならばansを1増やす、これ以上は探索しても意味が無いので打ち切る if(isSame(x, y)){ ans++; return ; // 答えじゃないけど、もうn個まで見てしまったか、積がaぴったし } else if(cnt >= n || y >= a){ return ; } // 見た数から、積がリミット以上になるまで for(int i = max; i * y <= a; ++i){ int tmp_x = x, tmp_y = y, tmp = 1, tmp_i = i; // 通分して、足す reduce(tmp_x, tmp_y, tmp, tmp_i); // 再帰 dfs(tmp_x + tmp, tmp_y, cnt + 1, i); } } int main() { while(cin >>p >>q >>a >>n && p){ ans = 0; // 再帰処理, 最初は 0 / 1 dfs(0, 1, 0, 1); cout <<ans <<endl; } return 0; }
a.cc: In function 'int main()': a.cc:71:9: error: 'cin' was not declared in this scope 71 | while(cin >>p >>q >>a >>n && p){ | ^~~ a.cc:18:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 17 | #include <ctime> +++ |+#include <iostream> 18 | using namespace std; a.cc:75:5: error: 'cout' was not declared in this scope 75 | cout <<ans <<endl; | ^~~~ a.cc:75:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s144302571
p00712
C++
#include <iostream> using namespace std; int a, n, x; int cnt, deno; void search( double p, double q , int x){ if( x / deno < 1 || ) return 0; if( x ) } int main(){ int p, q; while( cin >> p >> q >> a >> n && p ){ cnt = 0; deno = 2; } }
a.cc: In function 'void search(double, double, int)': a.cc:7:27: error: expected primary-expression before ')' token 7 | if( x / deno < 1 || ) return 0; | ^ a.cc:7:36: error: return-statement with a value, in function returning 'void' [-fpermissive] 7 | if( x / deno < 1 || ) return 0; | ^ a.cc:9:1: error: expected primary-expression before '}' token 9 | } | ^
s931747969
p00712
C++
#include<iostream> #include<algorithm> int all[8]; int max, maxcnt; int res = 0; int gcm(int a, int b){ if (b == 0)return a; else gcm(b, a%b); } int lcm(int a, int b){ int c = gcm(a, b); return a / c*b / c*c; } bool ask(int p, int q, int pp, int qq){ return p*qq >= pp*q; } std::pair<int, int> hiku(int p, int q, int pp, int qq){ int g = lcm(std::max(q, qq), std::min(q, qq)); int a = (p*g / q) - (pp*g / qq), b = g; int c = gcm(b, a); a /= c; b /= c; return std::make_pair(a, b); } void calc(int p, int q, int cnt){ int sum = 1; for (int i = 1; i < cnt; i++)sum *= all[i]; if (sum > max || cnt > maxcnt)return; if (p == 0)res++; for (int i = all[cnt - 1]; i < max; i++){ if (ask(p, q, 1, i)){ all[cnt] = i; std::pair<int, int> a = hiku(p, q, 1, i); calc(a.first, a.second, cnt + 1); } } } int main(){ int p, q; while (std::cin >> p >> q >> max >> maxcnt, p || q || max || maxcnt){ res = 0; memset(all, 0, sizeof(all)); maxcnt++; calc(p, q, 1); std::cout << res << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:56:17: error: 'memset' was not declared in this scope 56 | memset(all, 0, sizeof(all)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | a.cc: In function 'int gcm(int, int)': a.cc:10:17: warning: control reaches end of non-void function [-Wreturn-type] 10 | else gcm(b, a%b); | ~~~^~~~~~~~
s575638718
p00712
C++
#include <iostream> #include <cmath> using namespace std; int main() { int p, q, a, n, m[8]; while (cin >> p >> q >> a >> n, p || q || a || n){ int counter = 0; for (int i0 = 1; i0 <pow((double)a, (double)3 / (double)2); i0++){ m[0] = i0; if (n >= 1){ int s = q * m[0]; if (s * p / q == s / m[0]){ counter++; } } for (int i1 = 1; i1 <= i0; i1++){ m[1] = i1; if (m[0] * m[1] > a || n < 2){ break; } else{ int s = q * m[0] * m[1]; if (s * p / q == s / m[0] + s / m[1]){ counter++; } } for (int i2 = 1; i2 <= i1; i2++){ m[2] = i2; if (m[0] * m[1] * m[2] > a || n < 3){ break; } else{ int s = q * m[0] * m[1] * m[2]; if (s * p / q == s / m[0] + s / m[1] + s / m[2]){ counter++; } } for (int i3 = 1; i3 <= i2; i3++){ m[3] = i3; if (m[0] * m[1] * m[2] * m[3] > a || n < 4){ break; } else { int s = q * m[0] * m[1] * m[2] * m[3]; if (s * p / q == s / m[0] + s / m[1] + s / m[2] + s / m[3]){ counter++; } } for (int i4 = 1; i4 <= i3; i4++){ m[4] = i4; if (m[0] * m[1] * m[2] * m[3] * m[4] > a || n < 5){ break; } else { int s = q * m[0] * m[1] * m[2] * m[3] * m[4]; if (s * p / q == s / m[0] + s / m[1] + s / m[2] + s / m[3] + s / m[4]){ counter++; } } for (int i5 = 1; i5 <= i4; i5++){ m[5] = i5; if (m[0] * m[1] * m[2] * m[3] * m[4] * m[5] > a || n < 6){ break; } else{ int s = q * m[0] * m[1] * m[2] * m[3] * m[4] * m[5]; if (s * p / q == s / m[0] + s / m[1] + s / m[2] + s / m[3] + s / m[4] + s / m[5]){ counter++; } } for (int i6 = 1; i6 <= i5; i6++){ m[6] = i6; if (m[0] * m[1] * m[2] * m[3] * m[4] * m[5] * m[6] > a || n < 7){ break; } else{ int s = q * m[0] * m[1] * m[2] * m[3] * m[4] * m[5] * m[6]; if (s * p / q == s / m[0] + s / m[1] + s / m[2] + s / m[3] + s / m[4] + s / m[5] + s / m[6]){ counter++; } } } } } } } } } cout << counter << endl; } return 0;
a.cc: In function 'int main()': a.cc:95:18: error: expected '}' at end of input 95 | return 0; | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s181905850
p00712
C++
#include <iostream> using namespace std; class Frac{ public: int num, den; Frac():num(0), den(1){} Frac(const Frac &f):num(f.num), den(f.den){} Frac(int num_, int den_):num(num_), den(den_){} Frac& operator-=(const Frac &f){ int g = __gcd(den, f.den); Frac t((num * f.den - f.num * den) / g, den * f.den / g); g = __gcd(t.num, t.den); num = t.num / g; den = t.den / g; return *this; } }; inline Frac operator-(const Frac &lhs, const Frac &rhs){ Frac t(lhs); t -= rhs; return t; } int solve(Frac prev, int lo, int hi, int n){ if(prev.num == 0)return 1; if(n == 0)return 0; int res = 0; for(int d=lo; d<=hi; ++d)res += solve(prev - Frac(1, d), d, hi/d, n-1); return res; } int main(){ int p, q, a, n; while(cin >> p >> q >> a >> n, p|q|a|n)cout << solve(Frac(p, q), 1, a, n) << '\n'; return 0; }
a.cc: In member function 'Frac& Frac::operator-=(const Frac&)': a.cc:12:17: error: '__gcd' was not declared in this scope 12 | int g = __gcd(den, f.den); | ^~~~~
s079395748
p00713
C
#include"env.h" double X[300],Y[300],x,y,d,s,t,p,q; N,i,j,m,c; C(k){ c=0; for(k=N;k--;c>m?m=c:0) c+=k==i|k==j|hypot(X[k]-p,Y[k]-q)<1; } main(){ for(;scanf("%d",&N)*N;printf("%d \n",m)){ for(i=N;i--;) scanf("%lf%lf",X+i,Y+i); for(m=1;++i<N;) for(j=i;j--; d<2? s=(X[i]+X[j])/2,t=(Y[i]+Y[j])/2, x*=d=sqrt(1-d*d/4)/d,y*=d, p=s-y,q=t+x,C(),p=s+y,q=t-x,C() :0) d=hypot(x=X[i]-X[j],y=Y[i]-Y[j]); } }
main.c:1:9: fatal error: env.h: No such file or directory 1 | #include"env.h" | ^~~~~~~ compilation terminated.
s721161268
p00713
C
#include <iostream> #include <algorithm> #include <cmath> #include <complex> using namespace std; typedef complex<double> Point; const double EPS = 1e-8; int n; Point data[300]; int calc(Point a, Point b){ int res = 0; double d = abs(b - a) / 2.0; Point ab = (b - a) / (2.0 * d); if(d < 1){ Point o = ab * d; d = sqrt(1.0 - d * d); o += Point(d * ab.imag() + a.real(), -d * ab.real() + a.imag()); for(int i=0;i<n;i++){ if(abs(o - data[i]) < 1.0 + EPS) res++; } } return res; } main(){ while(cin >> n && n){ for(int i=0;i<n;i++){ cin >> data[i].imag() >> data[i].real(); } int ans = 1; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ ans = max(ans, calc(data[i], data[j])); ans = max(ans, calc(data[j], data[i])); } } cout << ans << endl; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s092674992
p00713
C++
#include <cstdio> #include <complex> #include <iostream> #define rep(i,n) for(int i=0;i<n;i++) #define re real() #define im imag() using namespace std; int main(){ while(true){ int n,mx=1; scanf("%d",&n); if(n==0) break; complex<double> p[300]; rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); rep(i,n) rep(j,i){ double d=abs(p[i]-p[j]); if(d>2) continue; complex<double> c=(p[i]+p[j])/2.0,dis=(p[i]-p[j])/d*sqrt(1-d*d/4); swap(dis.re,dis.im); dis.im=-dis.im; complex<double> cen=c+dis; int cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); cen=c-dis; cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); } printf("%d\n",mx); } return 0; }
a.cc: In function 'int main()': a.cc:5:16: error: lvalue required as unary '&' operand 5 | #define re real() | ^ a.cc:14:47: note: in expansion of macro 're' 14 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:6:16: error: lvalue required as unary '&' operand 6 | #define im imag() | ^ a.cc:14:56: note: in expansion of macro 'im' 14 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:19:29: error: no matching function for call to 'swap(double, double)' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/complex:44, from a.cc:2: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = double; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match) 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed: a.cc:6:16: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 6 | #define im imag() | ^ a.cc:19:41: note: in expansion of macro 'im' 19 | swap(dis.re,dis.im); | ^~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/istream:40, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'double' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)' 1226 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1226:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types '_Tp [_Nm]' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:19:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 19 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ a.cc:6:16: error: lvalue required as left operand of assignment 6 | #define im imag() | ^ a.cc:20:29: note: in expansion of macro 'im' 20 | dis.im=-dis.im; | ^~
s501784057
p00713
C++
#include <cstdio> #include <complex> #include <algorithm> #include <iostream> #define rep(i,n) for(int i=0;i<n;i++) #define re real() #define im imag() using namespace std; int main(){ while(true){ int n,mx=1; scanf("%d",&n); if(n==0) break; complex<double> p[300]; rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); rep(i,n) rep(j,i){ double d=abs(p[i]-p[j]); if(d>2) continue; complex<double> c=(p[i]+p[j])/2.0,dis=(p[i]-p[j])/d*sqrt(1-d*d/4); swap(dis.re,dis.im); dis.im=-dis.im; complex<double> cen=c+dis; int cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); cen=c-dis; cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); } printf("%d\n",mx); } return 0; }
a.cc: In function 'int main()': a.cc:6:16: error: lvalue required as unary '&' operand 6 | #define re real() | ^ a.cc:15:47: note: in expansion of macro 're' 15 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:7:16: error: lvalue required as unary '&' operand 7 | #define im imag() | ^ a.cc:15:56: note: in expansion of macro 'im' 15 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:20:29: error: no matching function for call to 'swap(double, double)' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/complex:44, from a.cc:2: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = double; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match) 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed: a.cc:7:16: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 7 | #define im imag() | ^ a.cc:20:41: note: in expansion of macro 'im' 20 | swap(dis.re,dis.im); | ^~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/istream:40, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'double' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)' 1226 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1226:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types '_Tp [_Nm]' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:20:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 20 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ a.cc:7:16: error: lvalue required as left operand of assignment 7 | #define im imag() | ^ a.cc:21:29: note: in expansion of macro 'im' 21 | dis.im=-dis.im; | ^~
s318040945
p00713
C++
#include <cstdio> #include <complex> #include <algorithm> #include <utility> #include <iostream> #define rep(i,n) for(int i=0;i<n;i++) #define re real() #define im imag() using namespace std; int main(){ while(true){ int n,mx=1; scanf("%d",&n); if(n==0) break; complex<double> p[300]; rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); rep(i,n) rep(j,i){ double d=abs(p[i]-p[j]); if(d>2) continue; complex<double> c=(p[i]+p[j])/2.0,dis=(p[i]-p[j])/d*sqrt(1-d*d/4); swap(dis.re,dis.im); dis.im=-dis.im; complex<double> cen=c+dis; int cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); cen=c-dis; cnt=0; rep(k,n) if(abs(cen-p[k])<=1.0000000001) cnt++; mx=max(mx,cnt); } printf("%d\n",mx); } return 0; }
a.cc: In function 'int main()': a.cc:7:16: error: lvalue required as unary '&' operand 7 | #define re real() | ^ a.cc:16:47: note: in expansion of macro 're' 16 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:8:16: error: lvalue required as unary '&' operand 8 | #define im imag() | ^ a.cc:16:56: note: in expansion of macro 'im' 16 | rep(i,n) scanf("%lf%lf",&p[i].re,&p[i].im); | ^~ a.cc:21:29: error: no matching function for call to 'swap(double, double)' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/complex:44, from a.cc:2: /usr/include/c++/14/bits/move.h:226:5: note: candidate: 'std::_Require<std::__not_<std::__is_tuple_like<_Tp> >, std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> > std::swap(_Tp&, _Tp&) [with _Tp = double; _Require<__not_<__is_tuple_like<_Tp> >, is_move_constructible<_Tp>, is_move_assignable<_Tp> > = void]' (near match) 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: conversion of argument 2 would be ill-formed: a.cc:8:16: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 8 | #define im imag() | ^ a.cc:21:41: note: in expansion of macro 'im' 21 | swap(dis.re,dis.im); | ^~ In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/istream:40, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: candidate: 'void std::__exception_ptr::swap(exception_ptr&, exception_ptr&)' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ /usr/include/c++/14/bits/exception_ptr.h:229:25: note: no known conversion for argument 1 from 'double' to 'std::__exception_ptr::exception_ptr&' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/sstream:1204:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringbuf<_CharT, _Traits, _Alloc>&, basic_stringbuf<_CharT, _Traits, _Alloc>&)' 1204 | swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1204:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1212:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_istringstream<_CharT, _Traits, _Allocator>&, basic_istringstream<_CharT, _Traits, _Allocator>&)' 1212 | swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1212:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1219:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_ostringstream<_CharT, _Traits, _Allocator>&, basic_ostringstream<_CharT, _Traits, _Allocator>&)' 1219 | swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1219:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/sstream:1226:5: note: candidate: 'template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(basic_stringstream<_CharT, _Traits, _Allocator>&, basic_stringstream<_CharT, _Traits, _Allocator>&)' 1226 | swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, | ^~~~ /usr/include/c++/14/sstream:1226:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/move.h:250:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> std::__enable_if_t<((bool)std::__is_swappable<_Tp>::value)> std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])' 250 | swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]) | ^~~~ /usr/include/c++/14/bits/move.h:250:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types '_Tp [_Nm]' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' 1089 | swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1089:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: candidate: 'template<class _T1, class _T2> typename std::enable_if<(! std::__and_<std::__is_swappable<_T1>, std::__is_swappable<_T2> >::value)>::type std::swap(pair<_T1, _T2>&, pair<_T1, _T2>&)' (deleted) 1106 | swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete; | ^~~~ /usr/include/c++/14/bits/stl_pair.h:1106:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::pair<_T1, _T2>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/basic_string.h:4039:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> void std::swap(__cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4039 | swap(basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~ /usr/include/c++/14/bits/basic_string.h:4039:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2805:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<std::__and_<std::__is_swappable<_Elements>...>::value>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' 2805 | swap(tuple<_Elements...>& __x, tuple<_Elements...>& __y) | ^~~~ /usr/include/c++/14/tuple:2805:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2823:5: note: candidate: 'template<class ... _Elements> typename std::enable_if<(! std::__and_<std::__is_swappable<_Elements>...>::value)>::type std::swap(tuple<_UTypes ...>&, tuple<_UTypes ...>&)' (deleted) 2823 | swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete; | ^~~~ /usr/include/c++/14/tuple:2823:5: note: template argument deduction/substitution failed: a.cc:21:29: note: mismatched types 'std::tuple<_UTypes ...>' and 'double' 21 | swap(dis.re,dis.im); | ~~~~^~~~~~~~~~~~~~~ a.cc:8:16: error: lvalue required as left operand of assignment 8 | #define im imag() | ^ a.cc:22:29: note: in expansion of macro 'im' 22 | dis.im=-dis.im; | ^~
s229191187
p00713
C++
#define _USE_MATH_DEFINES #include<iostream> #include<cstdio> #include<algorithm> #include<climits> #include<string> #include<vector> #include<list> #include<map> #include<set> #include<cmath> #include<queue> #include<cstring> #include<stack> using namespace std; #define EPS 1e-8 #define INF 1000000 struct Point{ double x,y; Point(){} Point(double _x,double _y){ x=_x; y=_y; } Point operator +(const Point p)const{ return Point(x+p.x,y+p.y); } Point operator -(const Point p)const{ return Point(x-p.x,y-p.y); } Point operator *(const double d)const{ return Point(x*d,y*d); } bool operator <(const Point &p)const{ if(x==p.x) return y<p.y; return x<p.x; } double norm(){ return x*x+y*y; } bool input(){ if(cin>>x>>y) return true; return false; } }; struct Line{ Point a,b; Line(){} Line(Point _a,Point _b){ a=_a; b=_b; } bool input(){ if(a.input() && b.input()) return true; return false; } }; struct Circle{ Point c; double r; Circle(){} Circle(Point _c,double _r){ c=_c; r=_r; } }; typedef vector<Point> Polygon; double dot(Point p,Point q){ return p.x*q.x+p.y*q.y; } double cross(Point p,Point q){ return p.x*q.y-q.x*p.y; } int ccw(Point a,Point b,Point c){ Point v1 = b-a; Point v2 = c-a; if(cross(v1,v2)>EPS) return +1; if(cross(v1,v2)<-EPS) return -1; if(dot(v1,v2)<-EPS) return +2; if(v1.norm()<v2.norm()) return -2; return 0; } bool intersect_ss(Line l,Line m){ return ccw(l.a,l.b,m.a)*ccw(l.a,l.b,m.b)<=0 && ccw(m.a,m.b,l.a)*ccw(m.a,m.b,l.b)<=0; } bool crosspoint_ll(Line l,Line m,Point &p){ Point a1,a2,b1,b2; a1 = l.b-l.a; a2 = m.b-m.a; b1 = m.a-l.a; b2 = l.a-m.b; double s1,s2; s1 = cross(a1,b1)/2; s2 = cross(a1,b2)/2; if(s1+s2<EPS) return false; p = Point(m.a.x+a2.x*s1/(s1+s2),m.a.y+a2.y*s1/(s1+s2)); return true; } int crosspoint_ss(Line l,Line m,Point &p){ if(intersect_ss(l,m)==false) return 0; if(crosspoint_ll(l,m,p)==true) return 1; return -1; } int crosspoint_cc(Circle c1,Circle c2,Point &p1,Point &p2){ double d,a,t; d = sqrt((c2.c-c1.c).norm()); if(abs(c1.c.x-c2.c.x)<EPS && abs(c1.c.y-c2.c.y)<EPS && abs(c1.r-c2.r)<EPS) return -1; if(d<abs(c1.r-c2.r) || c1.r+c2.r<d) return 0; a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d)); t = atan2(c2.c.y-c1.c.y,c2.c.x-c1.c.x); p1 = Point(c1.c.x+c1.r*cos(t+a),c1.c.y+c1.r*sin(t+a)); p2 = Point(c1.c.x+c1.r*cos(t-a),c1.c.y+c1.r*sin(t-a)); if(abs(p1.x-p2.x)<EPS && abs(p1.y-p2.y)<EPS) return 1; return 2; } int contains(Polygon g,Point p){ Line l = Line(p,Point(INF,p.y)); int cnt = 0, n = g.size(); for(int i=0;i<n;i++){ Point a = g[i]-p; Point b = g[(i+1)%n]-p; if(ccw(g[i],g[(i+1)%n],p)==0) return 1; if(a.y>b.y) swap(a,b); if(a.y<=EPS && EPS<b.y && cross(a,b)>EPS) cnt++; } if((cnt&1)==1) return 2; return 0; } Polygon andrewScan(Polygon s){ if(s.size()<=2) return s; sort(s.begin(),s.end()); Polygon g; for(int i=0;i<s.size();i++){ for(int n=g.size(); n>=2 && ccw(g[n-2],g[n-1],s[i])!=-1; n--){ g.pop_back(); } g.push_back(s[i]); } int upper_n = g.size(); for(int i=s.size()-2;i>=0;i--){ for(int n=g.size(); n>upper_n && ccw(g[n-2],g[n-1],s[i])!=-1; n--){ g.pop_back(); } g.push_back(s[i]); } reverse(g.begin(),g.end()); g.pop_back(); return g; } int cntInsidePoint(Circle c,Polygon s){ int cnt=0; for(int i=0;i<s.size();i++){ if((s[i]-c.c).norm()<=1.0) cnt++; } return cnt; } int main(){ int N; while(cin>>N,N){ Polygon S; S.resize(N); for(int i=0;i<N;i++) S[i].input(); int ans = 0; for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ Point p1,p2; if(crosspoint_cc(Circle(S[i],1),Circle(S[j],1),p1,p2)>0){ ans = max(ans,max(cntInsidePoint(Circle(p1,1),S),cntInsidePoint(Circle(p2,1),S))); } } } printf(\"%d\\n\",ans); } }
a.cc:182:24: error: stray '\' in program 182 | printf(\"%d\\n\",ans); | ^ a.cc:182:25: warning: missing terminating " character 182 | printf(\"%d\\n\",ans); | ^ a.cc:182:25: error: missing terminating " character 182 | printf(\"%d\\n\",ans); | ^~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:183:9: error: expected primary-expression before '}' token 183 | } | ^
s566768319
p00713
C++
#include<iostream> #include<algorithm> using namespace std; #define MAX_N 310 long double x[MAX_N], y[MAX_N]; int n, maxn; int main() { while (true) { cin >> n; if (n == 0) { break; } for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; } maxn = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { int sum = 0; long double X = (x[i] + x[j]) / 2.0; long double Y = (y[i] + y[j]) / 2.0; for (int k = 0; k < n; k++) { if (((x[k] - X)*(x[k] - X) + (y[k] - Y)*(y[k] - Y)) <= 1) { sum++; } } maxn = max(maxn, sum); long double X1, Y1, X2, Y2, X3, Y3, VX2, VY2, Dist, Dist2; Dist = sqrt((x[j] - x[i])*(x[j] - x[i]) + (y[j] - y[i])*(y[j] - y[i])); Dist2 = sqrt(4 - Dist*Dist); X2 = x[j] - x[i]; Y2 = y[j] - y[i]; VX2 = (X2 / Dist)*Dist2 / 2; VY2 = (Y2 / Dist)*Dist2 / 2; X1 = X + VY2; Y1 = Y - VX2; X3 = X - VY2; Y3 = Y + VX2; sum = 0; for (int k = 0; k < n; k++) { if (((x[k] - X1)*(x[k] - X1) + (y[k] - Y1)*(y[k] - Y1)) <= 1) { sum++; } } maxn = max(maxn, sum); sum = 0; for (int k = 0; k < n; k++) { if (((x[k] - X3)*(x[k] - X3) + (y[k] - Y3)*(y[k] - Y3)) <= 1) { sum++; } } maxn = max(maxn, sum); } } for (int i = 0; i < n; i++) { int sum = 0; long double X = x[i]; long double Y = y[i]; for (int k = 0; k < n; k++) { if (((x[k] - X)*(x[k] - X) + (y[k] - Y)*(y[k] - Y)) <= 1) { sum++; } } maxn = max(maxn, sum); } cout << maxn << endl; } return 0; }
a.cc: In function 'int main()': a.cc:30:40: error: 'sqrt' was not declared in this scope 30 | Dist = sqrt((x[j] - x[i])*(x[j] - x[i]) + (y[j] - y[i])*(y[j] - y[i])); | ^~~~
s965816272
p00713
C++
#include <cmath> #include <cstdio> #include <algorithm> ?? #define MAX_N 300 const double PI=acos(-1.0); ?? struct Point{ ????????double x,y; ????????Point(){ ????????????????x=y=0; ????????} ????????bool operator<(const Point& p)const{ ????????????????return this->x < p.x; ????????} }; ?? struct comp{ ????????bool operator()(const Point &P1, const Point &P2){ ????????????????return P1.x < P2.x; ????????} ????????bool operator()(const Point &P, double d){ ????????????????return P.x < d; ????????} ????????bool operator()(double d, const Point &P){ ????????????????return d < P.x; ????????} }; ?? Point points[MAX_N]; int N; ?? double distance(Point *a, Point *b){ ????????return std::sqrt(pow(a->x-b->x,2)+pow(a->y-b->y,2)); } ?? double distance2(Point *a, Point *b){ ????????return pow(a->x-b->x,2)+pow(a->y-b->y,2); } ?? int solve(){ ????????Point C, *P1, *P2, *P3; ????????int max=1; ????????for(int i=0;i<N;i++){ ????????????????P1=&points[i]; ????????????????Point *LB,*UB; ????????????????LB=std::lower_bound(points,points+N,P1->x-2.0001,comp()); ????????????????UB=std::upper_bound(points,points+N,P1->x+2.0001,comp()); ????????????????for(int j=(LB-points);j<(UB-points);j++){ ????????????????????????if(i==j) continue; ????????????????????????P2=&points[j]; ????????????????????????if(distance(P1,P2)>2.0) continue; ?? ????????????????????????double alpha,beta; ????????????????????????alpha=acos(distance(P1,P2)/2.0); ????????????????????????if((P2->x-P1->x)>=0){ ????????????????????????????????if((P2->y - P1->y)>=0){ ????????????????????????????????????????beta=atan((P2->y - P1->y) / (P2->x - P1->x)); ????????????????????????????????}else{ ????????????????????????????????????????beta=atan((P2->y - P1->y) / (P2->x - P1->x))+2.0*PI; ????????????????????????????????} ????????????????????????}else{ ????????????????????????????????beta=atan((P2->y - P1->y) / (P2->x - P1->x))+PI; ????????????????????????} ????????????????????????C.x=P1->x+cos(alpha+beta); ????????????????????????C.y=P1->y+sin(alpha+beta); ?? ????????????????????????int enclosed=0; ????????????????????????Point *lb,*ub; ????????????????????????lb=std::lower_bound(points,points+N,C.x-1.0001,comp()); ????????????????????????ub=std::upper_bound(points,points+N,C.x+1.0001,comp()); ????????????????????????for(int k=(lb-points);k<(ub-points);k++){ ????????????????????????????????if(k==i||k==j){ ????????????????????????????????????????enclosed++; ????????????????????????????????????????continue; ????????????????????????????????} ????????????????????????????????P3=&points[k]; ????????????????????????????????if(distance2(P3,&C)<1.0) enclosed++; ????????????????????????} ????????????????????????if(enclosed>max) max=enclosed; ????????????????????????if(max==N) return max; ????????????????} ????????} ????????return max; } ?? int main(void){ ????????while(scanf("%d",&N), N){ ????????????????for(int i=0;i<N;i++){ ????????????????????????scanf("%lf %lf", &points[i].x, &points[i].y); ????????????????} ????????????????std::sort(points,points+N); ????????????????printf("%d\n",solve()); ????????} ????????return 0; }
a.cc:4:1: error: expected unqualified-id before '?' token 4 | ?? | ^ a.cc:7:1: error: expected unqualified-id before '?' token 7 | ?? | ^ a.cc:17:1: error: expected unqualified-id before '?' token 17 | ?? | ^ a.cc:29:1: error: expected unqualified-id before '?' token 29 | ?? | ^ a.cc:32:1: error: expected unqualified-id before '?' token 32 | ?? | ^ a.cc:36:1: error: expected unqualified-id before '?' token 36 | ?? | ^ a.cc:40:1: error: expected unqualified-id before '?' token 40 | ?? | ^ a.cc:86:1: error: expected unqualified-id before '?' token 86 | ?? | ^
s333099454
p00713
C++
#include <complex> #include <cmath> #include <iostream> #include <vector> using namespace std; #define X real() #define Y imag() // ----- debug macro ----- #define DMPPT(p,stream) stream << (p).X << "," << (p).Y // ----- ----- ----- ----- // ???????§???????????§????????????£°????£°?????????????????????§???????????\?????¶????????????????????¶????????????????¨????????§???????????£??? typedef complex<double> PT; typedef complex<double> VC; // ??¶??´??±???or ??±?£?????????????????????´??????????£??????§???????????????????????VC get_vc_normal(VC a) { a = a * PT(0,-1); return a / abs(a); } int N; const double EPS = 1e-9; // rest code int main() { while(cin >> N, N) { vector<PT> p; for(int i = 0; i < N; i++) { double x, y; cin >> x >> y; p.push_back(PT(x,y)); } int res = 1; for(int i = 0; i < p.size(); i++) { for(int j = 0; j < p.size(); j++) { if(i == j) continue; VC a, b; PT c[2]; double len; a = (p[j] - p[i]) / 2.0; if(abs(a) > 1.0) continue; b = get_vc_normal(a); len = sqrt(1.0 - norm(a)); c[0] = p[i] + a + len*b; c[1] = p[i] + a - len*b; for(int k = 0; k < 2; k++) { int tmp = 0; for(int l = 0; l < p.size(); l++) { if(abs(c[k] - p[l]) < 1.0 + EPS) tmp++; } res = max(res, tmp); } } } cout << res << endl; } }
a.cc:19:9: error: 'a' does not name a type 19 | a = a * PT(0,-1); | ^ a.cc:20:9: error: expected unqualified-id before 'return' 20 | return a / abs(a); | ^~~~~~ a.cc:21:1: error: expected declaration before '}' token 21 | } | ^ a.cc: In function 'int main()': a.cc:45:37: error: 'get_vc_normal' was not declared in this scope 45 | b = get_vc_normal(a); | ^~~~~~~~~~~~~
s290618235
p00713
C++
#include <bits/stdc++.h> using namespace std; #define EPS 1e-8 typedef complex<double> Point; int main(){ int N; while(cin >> N,N){ Point p[N]; for(int i = 0 ; i < N ; i++){ cin >> p[i].real() >> p[i].imag(); } int res = 1; for(int i = 0 ; i < N-1 ; i++){ for(int j = i+1 ; j < N ; j++){ Point np = p[j]-p[i]; double d = abs(np); if(d + EPS > 2.0){ continue; } np /= d; np *= Point(0,1); Point cp = (p[i]+p[j])/2.0; Point v = sqrt(1.0-d*d/4.0)*np; int cnt = 2; Point center = cp + v; for(int k = 0 ; k < N ; k++){ if(i == k || j == k) continue; Point diff = center-p[k]; if(norm(diff) < 1.0 + EPS){ cnt++; } } res = max(res,cnt); } } cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:17: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double') 13 | cin >> p[i].real() >> p[i].imag(); | ~~~ ^~ ~~~~~~~~~~~ | | | | | double | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:13:29: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double' 13 | cin >> p[i].real() >> p[i].imag(); | ~~~~~~~~~^~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidat
s389268708
p00713
C++
#include <iostream> #include <vector> #include <cstdio> #include <algorithm> #include <cmath> #include <queue> #include <set> #include <functional> #include <ctime> using namespace std; #define fst first #define snd second #define all(c) ((c).begin()), ((c).end()) #define TEST(x,a) { auto y=(x); if (sign(y-a)) { cout << "line " << __LINE__ << #x << " = " << y << " != " << a << endl; exit(-1); } } double urand() { return rand() / (1.0 + RAND_MAX); } const double PI = acos(-1.0); // implementation note: use EPS only this function // usage note: check sign(x) < 0, sign(x) > 0, or sign(x) == 0 // notice: should be normalize to O(1) const double EPS = 1e-8; int sign(double x) { if (x < -EPS) return -1; if (x > +EPS) return +1; return 0; } struct point { typedef double T; T x, y; point &operator+=(point p) { x += p.x; y += p.y; return *this; } point &operator-=(point p) { x -= p.x; y -= p.y; return *this; } point &operator*=(T a) { x *= a; y *= a; return *this; } point &operator/=(T a) { return *this *= (1.0/a); } point operator-() const { return {-x, -y}; } bool operator==(point p) const { return !sign(x-p.x) && !sign(y-p.y); } bool operator!=(point p) const { return !operator==(p); } bool operator<(point p) const { return x!=p.x ? x<p.x : y<p.y; } // for sort }; point operator+(point p, point q) { return p += q; } point operator-(point p, point q) { return p -= q; } point operator*(point::T a, point p) { return p *= a; } point operator*(point p, point::T a) { return p *= a; } point operator/(point p, point::T a) { return p /= a; } point::T dot(point p, point q) { return p.x*q.x+p.y*q.y; } point::T cross(point p, point q) { return p.x*q.y-p.y*q.x; } // left turn > 0 point::T norm2(point p) { return dot(p,p); } point::T norm(point p) { return sqrt(dot(p,p)); } point::T dist(point p, point q) { return norm(p-q); } point orth(point p) { return {-p.y, p.x}; } istream &operator>>(istream &is, point &p) { is>>p.x>>p.y;return is; } ostream &operator<<(ostream &os, const point &p) { os<<"("<<p.x<<","<<p.y<<")"; return os; } int maximum_circle_cover(vector<point> ps, double r) { struct range { point p; // center double w; // width int hi; bool operator<(range r) const { return hi < r.hi; } }; double w = 0; for (point p: ps) w = max({w, abs(p.x), abs(p.y)}); priority_queue<range> que; que.push({{0,0}, w, (int)ps.size()}); point best_p; int best = 0; while (!que.empty()) { range R = que.top(); que.pop(); if (R.hi <= best) continue; //cout << "processing " << R.p << " " << R.w << " " << R.hi << "/" << best << endl; double dx[] = {1,-1,-1,1}, dy[] = {1,1,-1,-1}; for (int i = 0; i < 4; ++i) { range S = {R.p, R.w/2, 0}; S.p += S.w*point({dx[i], dy[i]}); int lo = 0; for (point q: ps) { auto d = dist(S.p, q); if (sign(d - r) <= 0) ++lo; if (sign(d - S.w*sqrt(2) - r) <= 0) ++S.hi; } if (lo > best) { best = lo; best_p = S.p; } best = max(lo, best); if (S.hi > best) que.push(S); } } return best; //best_p; } int maximum_circle_cover3(vector<point> ps, double r) { point best_p; int best = 0; function<void(point,double,vector<point>&)> rec = [&](point p, double w, vector<point> &ps) { w /= 2; const double dx[] = {1,-1,-1,1}, dy[] = {1,1,-1,-1}; point qs[4]; vector<point> pss[4]; for (int i = 0; i < 4; ++i) { qs[i] = p + w * point({dx[i], dy[i]}); int lo = 0; for (point q: ps) { auto d = dist(qs[i], q); if (sign(d - r) <= 0) ++lo; if (sign(d - w*sqrt(2) - r) <= 0) pss[i].push_back(q); } if (lo > best) { best = lo; best_p = qs[i]; } } int a = 0, b = 1, c = 2, d = 3; auto SW = [&](int &a, int &b) { if (pss[a].size() > pss[b].size()) swap(a, b); }; SW(a,b);SW(c,d);SW(b,d);SW(a,c);SW(b,c); if (pss[d].size() > best) rec(qs[d], w, pss[d]); if (pss[b].size() > best) rec(qs[b], w, pss[b]); if (pss[c].size() > best) rec(qs[c], w, pss[c]); if (pss[a].size() > best) rec(qs[a], w, pss[a]); }; double w = 0; for (point p: ps) w = max({w, abs(p.x), abs(p.y)}); rec({0,0}, w, ps); return best; //best_p; } int maximum_circle_cover2(vector<point> ps, double r) { int best = 0; for (point p: ps) { int count = 0; vector<pair<double,int>> aux; for (point q: ps) { auto d = dist(p, q); if (sign(d) == 0) ++count; else if (sign(d - 2*r) <= 0) { double theta = atan2(q.y-p.y, q.x-p.x); double phi = acos(min(1., d/(2*r))); aux.push_back({theta-phi, -1}); aux.push_back({theta+phi, +1}); } } sort(all(aux)); /* cout << "for point " << p << endl; for (auto a: aux) cout << "(" << a.fst << "," << a.snd << ") "; cout << endl; */ for (auto a: aux) best = max(best, count -= a.snd); } return best; } void verify_maximum_circle_cover2() { for (int n; scanf("%d", &n) && n; ) { vector<point> ps(n); for (int i = 0; i < n; ++i) scanf("%lf %lf", &ps[i].x, &ps[i].y); printf("%d\n", maximum_circle_cover1(ps, 1.0)); } } int main() { //verify_maximum_circle_cover(); verify_maximum_circle_cover2(); }
a.cc: In function 'void verify_maximum_circle_cover2()': a.cc:161:20: error: 'maximum_circle_cover1' was not declared in this scope; did you mean 'maximum_circle_cover3'? 161 | printf("%d\n", maximum_circle_cover1(ps, 1.0)); | ^~~~~~~~~~~~~~~~~~~~~ | maximum_circle_cover3
s718667233
p00713
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s335870521
p00713
C++
#include "bits/stdc++.h" using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; const LL MOD = 1000000007LL; const double EPS = 1e-10; struct Point { double x, y; Point(double x = 0, double y = 0) :x(x), y(y) {} Point operator+(Point &p) { return Point(x + p.x, y + p.y); } Point operator-(Point &p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x*a, y*a); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x*x + y*y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } }; typedef Point Vector; struct Segment { Point p1, p2; }; typedef Segment Line; struct Circle { Point c; double r; Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {} }; typedef vector<Point> Polygon; double norm(Vector a) { return a.x*a.x + a.y*a.y; } double abs(Vector a) { return sqrt(norm(a)); } double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; } double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; } bool equals(double a, double b) { return fabs(a - b) < EPS; } bool isOrthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); } bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } bool isOrthogonal(Segment s1, Segment s2) { return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); } bool isParallel(Point a1, Point a2, Point b1, Point b2) { return isParallel(a1 - a2, b1 - b2); } bool isParallel(Segment s1, Segment s2) { return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } Point project(Segment s, Point p) { Vector base = s.p2 - s.p1; double r = dot(p - s.p1, base) / norm(base); return s.p1 + base*r; } Point reflect(Segment s, Point p) { return p + (project(s, p) - p)*2.0; } static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } double getDistance(Point a, Point b) { return abs(a - b); } double getDistanceLP(Line l, Point p) { return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1)); } double getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2); return getDistanceLP(s, p); } bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0); } bool intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } double getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)), min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))); } bool intersect(Circle c, Line l) { return getDistanceLP(l, c.c) <= c.r; } bool intersect(Circle c1, Circle c2) { return getDistance(c1.c, c2.c) <= c1.r + c2.r; } Point getCrossPoint(Segment s1, Segment s2) { Vector base = s2.p2 - s2.p1; double d1 = abs(cross(base, s1.p1 - s2.p1)); double d2 = abs(cross(base, s1.p2 - s2.p1)); double t = d1 / (d1 + d2); return s1.p1 + (s1.p2 - s1.p1)*t; } pair<Point, Point> getCrossPoints(Circle c, Line l) { assert(intersect(c, l)); Vector pr = project(l, c.c); Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1); double base = sqrt(c.r*c.r - norm(pr - c.c)); return make_pair(pr + e*base, pr - e*base); } double arg(Vector p) { return atan2(p.y, p.x); } Vector polar(double a, double r) { return Vector(cos(r)*a, sin(r)*a); } pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { assert(intersect(c1, c2)); double d = abs(c1.c - c2.c); double a = acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r*d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } int main() { int N; while (cin >> N, N) { Point p[300]; for (int i = 0; i < N; i++) { double x, y; cin >> x >> y; p[i] = Point(x, y); } int ans = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { Vector d = p[j] - p[i]; if (d.abs() > 2.0) continue; Point m = p[i] + d / 2.0; Vector r = Vector(-d.y, d.x); r = r / r.abs()*sqrt(1 - pow(d.abs() / 2.0, 2)); Point p1 = m + r; Point p2 = m - r; int cnt1 = 0; int cnt2 = 0; for (int k = 0; k < N; k++) { if ((p[k] - p1).abs() <= 1) cnt1++; if ((p[k] - p2).abs() <= 1) cnt2++; } ans = max(ans, max(cnt1, cnt2)); } } cout << ans << endl; } }
a.cc: In function 'Point project(Segment, Point)': a.cc:83:21: error: no match for 'operator+' (operand types are 'Point' and 'Point') 83 | return s.p1 + base*r; | ~~~~ ^ ~~~~~~ | | | | Point Point a.cc:11:15: note: candidate: 'Point Point::operator+(Point&)' (near match) 11 | Point operator+(Point &p) { | ^~~~~~~~ a.cc:11:15: note: conversion of argument 1 would be ill-formed: a.cc:83:27: error: cannot bind non-const lvalue reference of type 'Point&' to an rvalue of type 'Point' 83 | return s.p1 + base*r; | ~~~~^~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::reverse_iterator<_Iterator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::move_iterator<_IteratorL>' 83 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:83:28: note: mismatched types 'const _CharT*' and 'Point' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:83:28: note: mismatched types 'const _CharT*' and 'Point' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:340:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::oper
s574381098
p00713
C++
#include "bits/stdc++.h" using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; const LL MOD = 1000000007LL; const double EPS = 1e-10; struct Point { double x, y; Point(double x = 0, double y = 0) :x(x), y(y) {} Point operator+(Point &p) { return Point(x + p.x, y + p.y); } Point operator-(Point &p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x*a, y*a); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x*x + y*y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } }; typedef Point Vector; struct Segment { Point p1, p2; }; typedef Segment Line; struct Circle { Point c; double r; Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {} }; typedef vector<Point> Polygon; double norm(Vector a) { return a.x*a.x + a.y*a.y; } double abs(Vector a) { return sqrt(norm(a)); } double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; } double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; } bool equals(double a, double b) { return fabs(a - b) < EPS; } bool isOrthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); } bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } bool isOrthogonal(Segment s1, Segment s2) { return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); } bool isParallel(Point a1, Point a2, Point b1, Point b2) { return isParallel(a1 - a2, b1 - b2); } bool isParallel(Segment s1, Segment s2) { return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } Point project(Segment s, Point p) { Vector base = s.p2 - s.p1; double r = dot(p - s.p1, base) / norm(base); return s.p1 + base*r; } Point reflect(Segment s, Point p) { return p + (project(s, p) - p)*2.0; } static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } double getDistance(Point a, Point b) { return abs(a - b); } double getDistanceLP(Line l, Point p) { return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1)); } double getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2); return getDistanceLP(s, p); } bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0); } bool intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } double getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)), min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))); } bool intersect(Circle c, Line l) { return getDistanceLP(l, c.c) <= c.r; } bool intersect(Circle c1, Circle c2) { return getDistance(c1.c, c2.c) <= c1.r + c2.r; } Point getCrossPoint(Segment s1, Segment s2) { Vector base = s2.p2 - s2.p1; double d1 = abs(cross(base, s1.p1 - s2.p1)); double d2 = abs(cross(base, s1.p2 - s2.p1)); double t = d1 / (d1 + d2); return s1.p1 + (s1.p2 - s1.p1)*t; } pair<Point, Point> getCrossPoints(Circle c, Line l) { assert(intersect(c, l)); Vector pr = project(l, c.c); Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1); double base = sqrt(c.r*c.r - norm(pr - c.c)); return make_pair(pr + e*base, pr - e*base); } double arg(Vector p) { return atan2(p.y, p.x); } Vector polar(double a, double r) { return Vector(cos(r)*a, sin(r)*a); } pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { assert(intersect(c1, c2)); double d = abs(c1.c - c2.c); double a = acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r*d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } int main() { int N; while (cin >> N, N) { Point p[300]; for (int i = 0; i < N; i++) { double x, y; cin >> x >> y; p[i] = Point(x, y); } int ans = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { Vector d = p[j] - p[i]; if (d.abs() > 2.0) continue; Point m = p[i] + d / 2.0; Vector r = Vector(-d.y, d.x); r = r / r.abs()*sqrt(1 - pow(d.abs() / 2.0, 2)); Point p1 = m + r; Point p2 = m - r; int cnt1 = 0; int cnt2 = 0; for (int k = 0; k < N; k++) { if ((p[k] - p1).abs() <= 1) cnt1++; if ((p[k] - p2).abs() <= 1) cnt2++; } ans = max(ans, max(cnt1, cnt2)); } } cout << ans << endl; } }
a.cc: In function 'Point project(Segment, Point)': a.cc:83:21: error: no match for 'operator+' (operand types are 'Point' and 'Point') 83 | return s.p1 + base*r; | ~~~~ ^ ~~~~~~ | | | | Point Point a.cc:11:15: note: candidate: 'Point Point::operator+(Point&)' (near match) 11 | Point operator+(Point &p) { | ^~~~~~~~ a.cc:11:15: note: conversion of argument 1 would be ill-formed: a.cc:83:27: error: cannot bind non-const lvalue reference of type 'Point&' to an rvalue of type 'Point' 83 | return s.p1 + base*r; | ~~~~^~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::reverse_iterator<_Iterator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::move_iterator<_IteratorL>' 83 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:83:28: note: mismatched types 'const _CharT*' and 'Point' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:83:28: note: mismatched types 'const _CharT*' and 'Point' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:83:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 83 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:340:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::oper
s957793116
p00713
C++
#include "bits/stdc++.h" using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; const LL MOD = 1000000007LL; const double EPS = 1e-10; struct Point { double x, y; Point(double x = 0, double y = 0) :x(x), y(y) {} Point operator+(Point &p) { return Point(x + p.x, y + p.y); } Point operator-(Point &p) { return Point(x - p.x, y - p.y); } Point operator*(double a) { return Point(x*a, y*a); } Point operator/(double a) { return Point(x / a, y / a); } double abs() { return sqrt(norm()); } double norm() { return x*x + y*y; } bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; } bool operator==(const Point &p) const { return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; } }; typedef Point Vector; struct Segment { Point p1, p2; }; typedef Segment Line; struct Circle { Point c; double r; Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {} }; typedef vector<Point> Polygon; double norm(Vector a); double abs(Vector a); double dot(Vector a, Vector b); double cross(Vector a, Vector b); bool equals(double a, double b); bool isOrthogonal(Vector a, Vector b); bool isOrthogonal(Point a1, Point a2, Point b1, Point b2); bool isOrthogonal(Segment s1, Segment s2); bool isParallel(Vector a, Vector b); bool isParallel(Point a1, Point a2, Point b1, Point b2); bool isParallel(Segment s1, Segment s2); Point project(Segment s, Point p); Point reflect(Segment s, Point p); int ccw(Point p0, Point p1, Point p2); double getDistance(Point a, Point b); double getDistanceLP(Line l, Point p); double getDistanceSP(Segment s, Point p); double getDistance(Segment s1, Segment s2); bool intersect(Point p1, Point p2, Point p3, Point p4); bool intersect(Segment s1, Segment s2); bool intersect(Circle c, Line l); bool intersect(Circle c1, Circle c2); Point getCrossPoint(Segment s1, Segment s2); pair<Point, Point> getCrossPoints(Circle c, Line l); double arg(Vector p); Vector polar(double a, double r); pair<Point, Point> getCrossPoints(Circle c1, Circle c2); double norm(Vector a) { return a.x*a.x + a.y*a.y; } double abs(Vector a) { return sqrt(norm(a)); } double dot(Vector a, Vector b) { return a.x*b.x + a.y*b.y; } double cross(Vector a, Vector b) { return a.x*b.y - a.y*b.x; } bool equals(double a, double b) { return fabs(a - b) < EPS; } bool isOrthogonal(Vector a, Vector b) { return equals(dot(a, b), 0.0); } bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) { return isOrthogonal(a1 - a2, b1 - b2); } bool isOrthogonal(Segment s1, Segment s2) { return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } bool isParallel(Vector a, Vector b) { return equals(cross(a, b), 0.0); } bool isParallel(Point a1, Point a2, Point b1, Point b2) { return isParallel(a1 - a2, b1 - b2); } bool isParallel(Segment s1, Segment s2) { return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0); } Point project(Segment s, Point p) { Vector base = s.p2 - s.p1; double r = dot(p - s.p1, base) / norm(base); return s.p1 + base*r; } Point reflect(Segment s, Point p) { return p + (project(s, p) - p)*2.0; } static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; int ccw(Point p0, Point p1, Point p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > EPS) return COUNTER_CLOCKWISE; if (cross(a, b) < -EPS) return CLOCKWISE; if (dot(a, b) < -EPS) return ONLINE_BACK; if (a.norm() < b.norm()) return ONLINE_FRONT; return ON_SEGMENT; } double getDistance(Point a, Point b) { return abs(a - b); } double getDistanceLP(Line l, Point p) { return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1)); } double getDistanceSP(Segment s, Point p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1); if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2); return getDistanceLP(s, p); } double getDistance(Segment s1, Segment s2) { if (intersect(s1, s2)) return 0.0; return min(min(getDistanceSP(s1, s2.p1), getDistanceSP(s1, s2.p2)), min(getDistanceSP(s2, s1.p1), getDistanceSP(s2, s1.p2))); } bool intersect(Point p1, Point p2, Point p3, Point p4) { return (ccw(p1, p2, p3)*ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1)*ccw(p3, p4, p2) <= 0); } bool intersect(Segment s1, Segment s2) { return intersect(s1.p1, s1.p2, s2.p1, s2.p2); } bool intersect(Circle c, Line l) { return getDistanceLP(l, c.c) <= c.r; } bool intersect(Circle c1, Circle c2) { return getDistance(c1.c, c2.c) <= c1.r + c2.r; } Point getCrossPoint(Segment s1, Segment s2) { Vector base = s2.p2 - s2.p1; double d1 = abs(cross(base, s1.p1 - s2.p1)); double d2 = abs(cross(base, s1.p2 - s2.p1)); double t = d1 / (d1 + d2); return s1.p1 + (s1.p2 - s1.p1)*t; } pair<Point, Point> getCrossPoints(Circle c, Line l) { assert(intersect(c, l)); Vector pr = project(l, c.c); Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1); double base = sqrt(c.r*c.r - norm(pr - c.c)); return make_pair(pr + e*base, pr - e*base); } double arg(Vector p) { return atan2(p.y, p.x); } Vector polar(double a, double r) { return Vector(cos(r)*a, sin(r)*a); } pair<Point, Point> getCrossPoints(Circle c1, Circle c2) { assert(intersect(c1, c2)); double d = abs(c1.c - c2.c); double a = acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r*d)); double t = arg(c2.c - c1.c); return make_pair(c1.c + polar(c1.r, t + a), c1.c + polar(c1.r, t - a)); } int main() { int N; while (cin >> N, N) { Point p[300]; for (int i = 0; i < N; i++) { double x, y; cin >> x >> y; p[i] = Point(x, y); } int ans = 0; for (int i = 0; i < N; i++) { for (int j = i + 1; j < N; j++) { Vector d = p[j] - p[i]; if (d.abs() > 2.0) continue; Point m = p[i] + d / 2.0; Vector r = Vector(-d.y, d.x); r = r / r.abs()*sqrt(1 - pow(d.abs() / 2.0, 2)); Point p1 = m + r; Point p2 = m - r; int cnt1 = 0; int cnt2 = 0; for (int k = 0; k < N; k++) { if ((p[k] - p1).abs() <= 1) cnt1++; if ((p[k] - p2).abs() <= 1) cnt2++; } ans = max(ans, max(cnt1, cnt2)); } } cout << ans << endl; } }
a.cc: In function 'Point project(Segment, Point)': a.cc:110:21: error: no match for 'operator+' (operand types are 'Point' and 'Point') 110 | return s.p1 + base*r; | ~~~~ ^ ~~~~~~ | | | | Point Point a.cc:11:15: note: candidate: 'Point Point::operator+(Point&)' (near match) 11 | Point operator+(Point &p) { | ^~~~~~~~ a.cc:11:15: note: conversion of argument 1 would be ill-formed: a.cc:110:27: error: cannot bind non-const lvalue reference of type 'Point&' to an rvalue of type 'Point' 110 | return s.p1 + base*r; | ~~~~^~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::reverse_iterator<_Iterator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::move_iterator<_IteratorL>' 110 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:110:28: note: mismatched types 'const _CharT*' and 'Point' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:110:28: note: mismatched types 'const _CharT*' and 'Point' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:110:28: note: 'Point' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 110 | return s.p1 + base*r; | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:340:5: note: candidate: 'template<class _Tp> std::comple
s118592844
p00713
C++
3 1 0 0 0 0 1 3 6.47634 7.69628 5.16828 4.79915 6.69533 6.20378 6 7.15296 4.08328 6.50827 2.69466 5.91219 3.86661 5.29853 4.16097 6.10838 3.46039 6.34060 2.41599 8 7.90650 4.01746 4.10998 4.18354 4.67289 4.01887 6.33885 4.28388 4.98106 3.82728 5.12379 5.16473 7.84664 4.67693 4.02776 3.87990 20 6.65128 5.47490 6.42743 6.26189 6.35864 4.61611 6.59020 4.54228 4.43967 5.70059 4.38226 5.70536 5.50755 6.18163 7.41971 6.13668 6.71936 3.04496 5.61832 4.23857 5.99424 4.29328 5.60961 4.32998 6.82242 5.79683 5.44693 3.82724 6.70906 3.65736 7.89087 5.68000 6.23300 4.59530 5.92401 4.92329 6.24168 3.81389 6.22671 3.62210 0
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s271804641
p00713
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int N; pair<double,double> dots[300]; int main(){ while(cin >> N && N != 0){ for(int i = 0; i < N; i++){ pair<double,double> p; cin >> dots[i].second >> dots[i].first; } int maxCnt = 1; // ‰~‚ðì‚邽‚߂̂Q“_‚ðŒˆ‚ß‚é for(int i = 0; i < N; i++){ for(int j = i+1; j < N; j++){ pair<double,double> dot1,dot2; dot1 = dots[i]; dot2 = dots[j]; double v = sqrt((dot1.first - dot2.first)*(dot1.first - dot2.first) +(dot1.second - dot2.second)*(dot1.second - dot2.second)); // “ñ“_ŠÔ‹——£‚ª2‚æ‚肨‚¨‚«‚¯‚ê‚΂‚­‚ê‚È‚¢ if(v > 2){ continue; } double x = sqrt(1 - (v/2)*(v/2)); // “ñ‘g‚Ì’PˆÊ–@üƒxƒNƒgƒ‹ pair<double,double> hose[2]; hose[0].first = -1.0/(dots[i].first - dots[j].first); hose[0].second = 1.0/(dots[i].second - dots[j].second); hose[1].first = 1.0/(dots[i].first - dots[j].first); hose[1].second = -1.0/(dots[i].second - dots[j].second); double dd1 = sqrt((hose[0].second)*(hose[0].second)+(hose[0].first)*(hose[0].first)); double dd2 = sqrt((hose[1].second)*(hose[1].second)+(hose[1].first)*(hose[1].first)); hose[0].first /= dd1; hose[0].second /= dd1; hose[1].first /= dd2; hose[1].second /= dd2; // x”{‚·‚é hose[0].first *= x;hose[1].first *= x; hose[0].second *= x;hose[1].second *= x; // m‚ð‘«‚· hose[0].first += (dot1.first + dot2.first)/2; hose[0].second += (dot1.second + dot2.second)/2; hose[1].first += (dot1.first + dot2.first)/2; hose[1].second += (dot1.second + dot2.second)/2; // hose[0]‚Æhose[1]‚͉~‚Ì’†SÀ•W // Še“_‚ÉŠÖ‚µ‚ĉ~‚Ì’†‚É‘¶Ý‚·‚é‚©‚Ç‚¤‚©‚ð‹‚ß‚é for(int k = 0; k < 2; k++){ int cnt = 0; for(int l = 0; l < N; l++){ double dist = sqrt((dots[l].first -hose[k].first)*(dots[l].first -hose[k].first) + (dots[l].second -hose[k].second)*(dots[l].second -hose[k].second)); if(dist <= 1){ cnt++; } } maxCnt = max(maxCnt,cnt); } } } cout << maxCnt << endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:44: error: 'sqrt' was not declared in this scope 25 | double v = sqrt((dot1.first - dot2.first)*(dot1.first - dot2.first) | ^~~~
s187100665
p00713
C++
import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); while(true){ final int n = sc.nextInt(); if(n == 0){ break; } Point2D[] points = new Point2D[n]; for(int i = 0; i < n; i++){ points[i] = new Point2D(sc.nextDouble(), sc.nextDouble()); } int max = 0; for(int fst = 0; fst < n; fst++){ for(int snd = 0; snd < n; snd++){ Point2D[] cross = Point2D.cross_ss(points[fst], 1, points[snd], 1); for(Point2D cross_c : cross){ int count = 0; for(int i = 0; i < n; i++){ if(cross_c.dist(points[i]) <= 1.0 + Point2D.EPS){ count++; } } max = Math.max(max, count); } } } System.out.println(max); } } } class Point2D { public double x; public double y; public static final double EPS = 1e-4; public Point2D(double x, double y) { this.x = x; this.y = y; } public Point2D(Point2D point) { this.x = point.x; this.y = point.y; } public String toString() { return x + "," + y; } @Override public boolean equals(Object o) { if (o instanceof Point2D) { Point2D another = (Point2D) o; if (this.x - EPS < another.x && this.x + EPS > another.x && this.y - EPS < another.y && this.y + EPS > another.y) { return true; } return false; // return this.x == another.x && this.y == another.y; } return false; } public Point2D add(double x, double y) { return new Point2D(this.x + x, this.y + y); } public Point2D sub(double x, double y) { return add(-x, -y); } public Point2D add(Point2D another) { return add(another.x, another.y); } public Point2D sub(Point2D another) { return sub(another.x, another.y); } public Point2D mul(double d) { return new Point2D(this.x * d, this.y * d); } public Point2D div(double d) { return new Point2D(this.x / d, this.y / d); } public double dot(double x, double y) { return this.x * x + this.y * y; } public double dot(Point2D another) { return dot(another.x, another.y); } public double cross(double x, double y) { return this.x * y - this.y * x; } public double cross(Point2D another) { return cross(another.x, another.y); } public double dist(double x, double y) { return Math.sqrt((this.x - x) * (this.x - x) + (this.y - y) * (this.y - y)); } public double dist(Point2D another) { return dist(another.x, another.y); } public double dist_o() { return dist(0, 0); } public Point2D unit() { return div(dist_o()); } public boolean pol(Point2D start, Point2D end) { return end.sub(start).cross(this.sub(start)) < EPS; } public boolean pos(Point2D start, Point2D end) { return (start.dist(this) + this.dist(end) < start.dist(end) + EPS); } public double pld(Point2D start, Point2D end) { return Math.abs((end.sub(start).cross(this.sub(start))) / end.sub(start).dist_o()); } public double psd(Point2D start, Point2D end) { if (end.sub(start).dot(this.sub(start)) < EPS) { return this.dist(start); } else if (start.sub(end).dot(this.sub(end)) < EPS) { return this.dist(end); } else { return end.sub(start).cross(this.sub(start)) / end.dist(start); } } public static boolean intersect_s(Point2D a1, Point2D a2, Point2D b1, Point2D b2) { return (a2.sub(a1).cross(b1.sub(a1)) * a2.sub(a1).cross(b2.sub(a1)) < EPS) && (b2.sub(b1).cross(a1.sub(b1)) * b2.sub(b1).cross(a2.sub(b1)) < EPS); } public static boolean insersect_l(Point2D a1, Point2D a2, Point2D b1, Point2D b2) { return a1.sub(a2).cross(b1.sub(b2)) < EPS; } public static Point2D interpoint_s(Point2D a1, Point2D a2, Point2D b1, Point2D b2) { Point2D b = b2.sub(b1); double d1 = Math.abs(b.cross(a1.sub(b1))); double d2 = Math.abs(b.cross(a2.sub(b1))); double t = d1 / (d1 + d2); Point2D a = a2.sub(a1), v = a.mul(t); return a1.add(v); } public static Point2D interpoint_l(Point2D a1, Point2D a2, Point2D b1, Point2D b2) { Point2D a = a2.sub(a1); Point2D b = b2.sub(b1); double t = b.cross(b1.sub(a1)) / b.cross(a); Point2D v = a.mul(t); return a1.add(v); } public static Point2D[] cross_ss(Point2D p1, double r1, Point2D p2, double r2) { double dis = p1.dist(p2); if (r1 + EPS > r2 && r1 - EPS < r2 && dis < EPS) { return new Point2D[0]; // same } if (dis - EPS < r1 + r2 && dis + EPS > r1 + r2) { Point2D tmp = p2.sub(p1); tmp = tmp.mul(r1 / tmp.dist_o()); Point2D ret[] = new Point2D[1]; ret[0] = p1.add(tmp); return ret; } else if (dis + EPS > r1 + r2) { return new Point2D[0]; // out } double dis_m = Math.abs(r1 - r2); if (dis_m + EPS > dis && dis_m - EPS < dis) { Point2D tmp = null; if (r1 > r2) { tmp = p2.sub(p1); } else { tmp = p1.sub(p2); } double min = Math.min(r1, r2); tmp = tmp.mul((min + tmp.dist_o()) / tmp.dist_o()); Point2D ret[] = new Point2D[1]; ret[0] = p1.add(tmp); return ret; } else if (dis_m + EPS > dis) { return new Point2D[0]; // inner } else { Point2D ret[] = new Point2D[2]; double theta = Math.acos((dis * dis + r1 * r1 - r2 * r2) / (2 * dis * r1)); double a = Math.atan2(p2.y - p1.y, p2.x - p1.x); ret[0] = new Point2D(r1 * Math.cos(a + theta) + p1.x, r1 * Math.sin(a + theta) + p1.y); ret[1] = new Point2D(r1 * Math.cos(a - theta) + p1.x, r1 * Math.sin(a - theta) + p1.y); return ret; } } public void interpoint_lc(Point2D start, Point2D end, Point2D c, double r, Point2D ans[]) { if (c.pld(start, end) > r + EPS) return; Point2D v = end.sub(start).unit(); double delta = v.dot(start.sub(c)) * v.dot(start.sub(c)) - start.dist(c) * start.dist(c) + r * r; double t = -v.dot(start.sub(c)); double s = Math.sqrt(delta); ans[0] = start.add(v.mul(t + s)); ans[1] = start.add(v.mul(t + s)); } public Point2D normal_vector(Point2D p, Point2D a, Point2D b) { Point2D v = b.sub(a).unit(); v = v.cross(p.sub(a)) > 0 ? new Point2D(v.y, (-1) * v.x) : new Point2D( (-1) * v.y, v.x); return v.mul(p.pld(a, b)); } public double area(Point2D a, Point2D b, Point2D c) { return Math.abs((c.sub(a).cross(b.sub(a))) * 0.5); } }
a.cc:76:5: error: stray '@' in program 76 | @Override | ^ a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.HashMap; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.LinkedList; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.PriorityQueue; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.Scanner; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: expected unqualified-id before 'public' 9 | public class Main { | ^~~~~~ a.cc:57:11: error: expected ':' before 'double' 57 | public double x; | ^~~~~~~ | : a.cc:58:11: error: expected ':' before 'double' 58 | public double y; | ^~~~~~~ | : a.cc:60:11: error: expected ':' before 'static' 60 | public static final double EPS = 1e-4; | ^~~~~~~ | : a.cc:60:19: error: 'final' does not name a type 60 | public static final double EPS = 1e-4; | ^~~~~ a.cc:62:11: error: expected ':' before 'Point2D' 62 | public Point2D(double x, double y) { | ^~~~~~~~ | : a.cc:67:11: error: expected ':' before 'Point2D' 67 | public Point2D(Point2D point) { | ^~~~~~~~ | : a.cc:67:12: error: invalid constructor; you probably meant 'Point2D (const Point2D&)' 67 | public Point2D(Point2D point) { | ^~~~~~~ a.cc:72:11: error: expected ':' before 'String' 72 | public String toString() { | ^~~~~~~ | : a.cc:72:12: error: 'String' does not name a type 72 | public String toString() { | ^~~~~~ a.cc:76:6: error: 'Override' does not name a type 76 | @Override | ^~~~~~~~ a.cc:92:11: error: expected ':' before 'Point2D' 92 | public Point2D add(double x, double y) { | ^~~~~~~~ | : a.cc:96:11: error: expected ':' before 'Point2D' 96 | public Point2D sub(double x, double y) { | ^~~~~~~~ | : a.cc:100:11: error: expected ':' before 'Point2D' 100 | public Point2D add(Point2D another) { | ^~~~~~~~ | : a.cc:104:11: error: expected ':' before 'Point2D' 104 | public Point2D sub(Point2D another) { | ^~~~~~~~ | : a.cc:108:11: error: expected ':' before 'Point2D' 108 | public Point2D mul(double d) { | ^~~~~~~~ | : a.cc:112:11: error: expected ':' before 'Point2D' 112 | public Point2D div(double d) { | ^~~~~~~~ | : a.cc:116:11: error: expected ':' before 'double' 116 | public double dot(double x, double y) { | ^~~~~~~ | : a.cc:120:11: error: expected ':' before 'double' 120 | public double dot(Point2D another) { | ^~~~~~~ | : a.cc:124:11: error: expected ':' before 'double' 124 | public double cross(double x, double y) { | ^~~~~~~ | : a.cc:128:11: error: expected ':' before 'double' 128 | public double cross(Point2D another) { | ^~~~~~~ | : a.cc:132:11: error: expected ':' before 'double' 132 | public double dist(double x, double y) { | ^~~~~~~ | : a.cc:137:11: error: expected ':' before 'double' 137 | public double dist(Point2D another) { | ^~~~~~~ | : a.cc:141:11: error: expected ':' before 'double' 141 | public double dist_o() { | ^~~~~~~ | : a.cc:145:11: error: expected ':' before 'Point2D' 145 | public Point2D unit() { | ^~~~~~~~ | : a.cc:149:11: error: expected ':' before 'boolean' 149 | public boolean pol(Point2D start, Point2D end) { | ^~~~~~~~ | : a.cc:149:12: error: 'boolean' does not name a type; did you mean 'bool'? 149 | public boolean pol(Point2D start, Point2D end) { | ^~~~~~~ | bool a.cc:153:11: error: expected ':' before 'boolean' 153 | public boolean pos(Point2D start, Point2D end) { | ^~~~~~~~ | : a.cc:153:12: error: 'boolean' does not name a type; did you mean 'bool'? 153 | public boolean pos(Point2D start, Point2D end) { | ^~~~~~~ | bool a.cc:157:11: error: expected ':' before 'double' 157 | public double pld(Point2D start, Point2D end) { | ^~~~~~~ | : a.cc:162:11: error: expected ':' before 'double' 162 | public double psd(Point2D start, Point2D end) { | ^~~~~~~ | : a.cc:172:11: error: expected ':' before 'static' 172 | public static boolean intersect_s(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | : a.cc:172:19: error: 'boolean' does not name a type; did you mean 'bool'? 172 | public static boolean intersect_s(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | bool a.cc:178:11: error: expected ':' before 'static' 178 | public static boolean insersect_l(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | : a.cc:178:19: error: 'boolean' does not name a type; did you mean 'bool'? 178 | public static boolean insersect_l(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | bool a.cc:183:11: error: expected ':' before 'static' 183 | public static Point2D interpoint_s(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | : a.cc:193:11: error: expected ':' before 'static' 193 | public static Point2D interpoint_l(Point2D a1, Point2D a2, Point2D b1, | ^~~~~~~ | : a.cc:202:11: error: expected ':' before 'static' 202 | public static Point2D[] cross_ss(Point2D p1, double r1, Point2D p2, | ^~~~~~~ | : a.cc:202:26: error: expected unqualified-id before '[' token 202 | public static Point2D[] cross_ss(Point2D p1, double r1, Point2D p2, | ^ a.cc:254:11: error: expected ':' before 'void' 254 | public void interpoint_lc(Point2D start, Point2D end, Point2D c, double r, | ^~~~~ | : a.cc:267:11: error: expected ':' before 'Point2D' 267 | public Point2D normal_vector(Point2D p, Point2D a, Point2D b) { | ^~~~~~~~ | : a.cc:274:11: error: expected ':' before 'double' 274 | public double area(Point2D a, Point2D b, Point2D c) { | ^~~~~~~ | : a.cc:278:2: error: expected ';' after class definition 278 | } | ^ | ; a.cc: In constructor 'Point2D::Point2D(double, double)': a.cc:63:14: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 63 | this.x = x; | ^ a.cc:64:14: error: request for member 'y' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 64 | this.y = y; | ^ a.cc: In member function 'Point2D Point2D::add(double, double)': a.cc:93:33: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 93 | return new Point2D(this.x + x, this.y + y); | ^ a.cc:93:45: error: request for member 'y' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 93 | return new Point2D(this.x + x, this.y + y); | ^ a.cc: In member function 'Point2D Point2D::mul(double)': a.cc:109:33: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 109 | return new Point2D(this.x * d, this.y * d); | ^ a.cc:109:45: error: request for member 'y' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 109 | return new Point2D(this.x * d, this.y * d); | ^ a.cc: In member function 'Point2D Point2D::div(double)': a.cc:113:33: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 113 | return new Point2D(this.x / d, this.y / d); | ^ a.cc:113:45: error: request for member 'y' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 113 | return new Point2D(this.x / d, this.y / d); | ^ a.cc: In member function 'double Point2D::dot(double, double)': a.cc:117:21: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 117 | return this.x * x + this.y * y; | ^ a.cc:117:34: error: request for member 'y' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 117 | return this.x * x + this.y * y; | ^ a.cc: In member function 'double Point2D::cross(double, double)': a.cc:125:21: error: request for member 'x' in '(Point2D*)this', which is of pointer type 'Point2D*' (maybe you meant to use '->' ?) 125 | return this.x * y - this.y * x; | ^ a.cc:125:34: erro