intmain(){ int n = 0, l = 0, h = 0; cin >> n >> l >> h; vector<struct Stu> v1, v2, v3, v4; for (int i = 0; i < n; i++) { structStu temp; cin >> temp.id; scanf("%d %d", &temp.de, &temp.cai);
if (temp.de >= l && temp.cai >= l) { if (temp.de >= h && temp.cai >= h) { v1.push_back(temp); } elseif (temp.de >= h) { v2.push_back(temp); } elseif (temp.de < h && temp.cai < h && temp.de >= temp.cai) { v3.push_back(temp); } else { v4.push_back(temp); } } }
每个输入包含1个测试用例。每个测试用例第1行给出第1个结点的地址、结点总个数正整数N(<= 105)、以及正整数K(<=N),即要求反转的子链结点的个数。结点的地址是5位非负整数,NULL地址用-1表示。 接下来有N行,每行格式为: Address Data Next 其中Address是结点地址,Data是该结点保存的整数数据,Next是下一结点的地址。
intmain(){ int n = 0, p = 0; cin >> n >> p; longlong a[100001]; for (int i = 0; i < n; i++) { cin >> a[i]; } if (n == 0 || p < 0) { cout << n; return0; }
sort(a, a + n);
long cnt = 1; for (int i = n - 1; i >= 1; i--) { int temp = 1; longlong M = a[i]; for (int j = i - cnt; j >= 0 && M * 1.0 / a[j] <= p; j--) { temp = i - j + 1; } cnt = cnt > temp ? cnt : temp; }
intmain(){ int *score = newint[101]; int n = 0; cin >> n; for (int i = 0; i < n; i++) { int temp = 0; cin >> temp; score[temp]++; } int k = 0; cin >> k; for (int i = 0; i < k - 1; i++) { int temp = 0; cin >> temp; cout << score[temp] << " "; } int temp = 0; cin >> temp; cout << score[temp];