T1
1 2 3 4 5 6 7 8 | #include<iostream> using namespace std; int main() { double a, b, c; cin >> a >> b >> c; long long re = 0.2*a + 0.3*b + 0.5*c; cout << re; } |
T2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include<iostream> #include<vector> #include<string> #include<algorithm> using namespace std; bool cmp(string s1, string s2) { if (s1.length() != s2.length())return s1.length() < s2.length(); return s1 < s2; } int main() { int n, q; vector<string> arr; cin >> n >> q; for (int i = 1; i <= n; i++) { string tmp; cin >> tmp; arr.push_back(tmp); } sort(arr.begin(), arr.end(), cmp); for (int i = 1; i <= q; i++) { int tmpi; string tmp; cin >> tmpi >> tmp; bool flag = false; for (vector<string>::iterator ptr = arr.begin(); ptr != arr.end(); ptr++) { if (ptr->length() - tmp.length() <=1e9 && ptr->substr(ptr->length() - tmp.length()) == tmp) { flag = true; cout << (*ptr) << endl; break; } } if (!flag)cout << "-1" << endl; } } |