[Codeforces] #420 (Div. 2)
題目連結: http://codeforces.com/contest/821 #A 照著敘述做就好。 # include < iostream > using namespace std; int a[ 60 ][ 60 ]; int main (){ int n;cin >> n; for(int i = 0 ; i < n ; i++) for(int j = 0; j < n ; j++) cin >> a[i][j]; for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < n ; j++){ if(a[i][j] != 1){ bool flag = 0; for(int s = 0 ; s < n ; s++) for(int p = 0 ; p < n ; p++) if(a[i][s] + a[p][j] == a[i][j]) flag = 1; if(!flag){ puts("No"); return 0; } } } } puts("Yes"); return 0; } #B 枚舉所有Y點,然後O(1)判斷那個點可以拿幾根香蕉。 # include < iostream > # include < cmath > using namespace std; long long m,b; long long a (long long y){return (y-b)*-m;} long long check (...