CodeForces Round#313

來源:互聯網
上載者:User

標籤:

第一題想當然了,結果被坑。。

有1的肯定能構成所有的其他數,沒有1的肯定構不成1 ,這題T T

#include <iostream>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;int main(){      int n, arr;      int tag = 0;      scanf("%d", &n);      for(int i = 0; i < n; ++i) {            scanf("%d", &arr);            tag = (arr == 1 || tag == 1) ? 1 : 0;      }      if(tag) cout << -1 << endl;      else cout << 1 << endl;      return 0;}

第二題,就是考慮的邊界有點多。

#include<bits/stdc++.h>using namespace std;int main() {      int b[2];      int p1[2], p2[2];      cin >> b[0] >> b[1] >> p1[0] >> p1[1] >> p2[0] >> p2[1];      sort(b, b+2); sort(p1, p1+2); sort(p2, p2+2);      if((p1[0] * p1[1] + p2[0] * p2[1]) > (b[0] * b[1]) || p2[1] > b[1] || p1[1] > b[1] ) {            cout << "NO" << endl;      } else {            int tag = 0;            int x[4];            x[0] = b[0] - p1[0];            x[2] = b[1] - p1[1];            x[1] = b[0] - p1[1];            x[3] = b[1] - p1[0];            if(p2[0] <= min(x[0], b[1]) && p2[1] <= max(x[0], b[1]))                  tag = 1; //cout << 1 << endl;            else if (p2[0] <= min(x[2], b[0]) && p2[1] <= max(x[2], b[0]))                   tag = 1; //cout << 2 << endl;            else if(p2[0] <= min(x[1], b[1]) && p2[1] <= max(x[1], b[1]))                   tag = 1; //cout << 3 << endl;            else if(p2[0] <= min(x[3], b[0]) && p2[1] <= max(x[3], b[0]))                   tag = 1; //cout << 4 << endl; cout << x[3] << b[1] << endl;            if(tag)                  cout << "YES" << endl;            else                  cout << "NO" << endl;      }      return 0;}

第三題,就是算個等角六邊形的面積,可以補成大矩形算,也可以補成大正三角形算。用分割的方法反而複雜許多,而且還遇到精度丟失問題

#include <bits/stdc++.h>using namespace std;int main() {      int a[6];      for(int i = 0; i < 6; ++i)            cin >> a[i];      cout << (a[0] + a[1] + a[2])*(a[0] + a[1] + a[2])-a[0] * a[0] - a[2] * a[2] - a[4] * a[4] << endl;      return 0;}

CodeForces Round#313

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.