結果
問題 | No.751 Frac #2 |
ユーザー | aaa |
提出日時 | 2018-11-09 22:46:43 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,323 bytes |
コンパイル時間 | 893 ms |
コンパイル使用メモリ | 98,124 KB |
実行使用メモリ | 4,508 KB |
最終ジャッジ日時 | 2023-08-13 11:58:19 |
合計ジャッジ時間 | 2,340 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
4,380 KB |
testcase_08 | WA | - |
testcase_09 | AC | 1 ms
4,376 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 1 ms
4,376 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 2 ms
4,380 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
ソースコード
#include <stdio.h> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <functional> #include <map> #include <iomanip> #include <math.h> #include <stack> #include <queue> #include <bitset> #include <cstdlib> #include <tuple> #include <cctype> #include <ctype.h> #include <set> #include <sstream> using namespace std; int main() { int i, j; int n1, n2; //vector<double>a, b; vector<long long>a, b; int mai1 = 0, mai2 = 0; cin >> n1; for (i = 0; i < n1; i++) { //double num; long long num; cin >> num; a.push_back(num); if (num < 0) mai1++; } cin >> n2; for (i = 0; i < n2; i++) { //double num; long long num; cin >> num; b.push_back(num); if (num < 0) mai2++; } //double ans1 = 0, ans2 = 0; long long ans1 = 0, ans2 = 0; a[0] = abs(a[0]); b[0] = abs(b[0]); if (n2 >= 2) { for (i = b.size() - 1; i >= 1; i--) { //a[0] *= b[i]; a[0] *= abs( b[i]); } } if (n1 >= 2) { for (i = a.size() - 1; i >= 1; i--) { //b[0] *= a[i]; b[0] *= abs( a[i]); } } vector<long long>slist{ 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157 ,163 ,167 ,173 ,179 ,181 ,191 ,193 ,197 ,199 ,211 ,223 ,227 ,229 ,233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 }; while (true) { bool flag = false; for (i = 0; i < slist.size(); i++) { if (a[0] % slist[i] == 0 && b[0] % slist[i] == 0) { a[0] /= slist[i]; b[0] /= slist[i]; flag = true; } } if (flag == false) break; } if (mai1 == 0 || mai1 % 2 == 0) { mai1 = 0; } else { mai1 = 1; } if (mai2 == 0 || mai2 % 2 == 0) { mai2 = 0; } else { mai2 = 1; } if (mai1 == 1) { a[0] = 0 - abs(a[0]); } if (mai2 == 1) { b[0] = 0 - abs(b[0]); } cout << a[0] << " " << b[0] << endl; //if (n1 == 1) { // ans1 = a[0]; //} //else { // ans1 = a[0]; // for (i = 1; i < n1; i++) { // //ans1 = a[i] / a[i + 1]; // ans1 = ans1 / a[i]; // } //} //if (n2 == 1) { // ans2 = b[0]; //} //else { // ans2 = b[0]; // for (i = 1; i < n2; i++) { // //ans2 = b[i] / b[i + 1]; // ans2 = ans2 / b[i]; // } //} //double ans3 = (ans1 / ans2); //cout << ans3 << " " << 1 << endl; getchar(); getchar(); return 0; }