ACM
This commit is contained in:
parent
e59ed31afe
commit
504cf57178
28
ACM/CQUPT-19/B.cpp
Normal file
28
ACM/CQUPT-19/B.cpp
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
long long xors(long long n) {
|
||||||
|
const long long X = 1000000007;
|
||||||
|
if (n * n < X) {
|
||||||
|
return n % 2;
|
||||||
|
}
|
||||||
|
long long result = 0;
|
||||||
|
long long j = 1;
|
||||||
|
while (j <= n) {
|
||||||
|
long long val = X / j;
|
||||||
|
long long left = j;
|
||||||
|
long long right = min(n, X / val);
|
||||||
|
long long count = right - left + 1;
|
||||||
|
result ^= count;
|
||||||
|
j = right + 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin >> t;
|
||||||
|
while (t-- > 0) {
|
||||||
|
long long n;
|
||||||
|
cin >> n;
|
||||||
|
cout << xors(n) << endl;
|
||||||
|
}
|
||||||
|
}
|
25
ACM/CQUPT-19/C.cpp
Normal file
25
ACM/CQUPT-19/C.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <stdio.h>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
int t;
|
||||||
|
cin>>t;
|
||||||
|
while(t-->0) {
|
||||||
|
int n,m;
|
||||||
|
cin>>n>>m;
|
||||||
|
int arr1[n][m],arr2[m][n];
|
||||||
|
for(int i=0;i<n;i++) {
|
||||||
|
for(int j=0;j<m;j++) {
|
||||||
|
cin>>arr1[i][j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i = 0; i < m; i++)
|
||||||
|
{
|
||||||
|
for(int j = 0; j < n; j++){
|
||||||
|
printf("%d", arr1[j][i]);
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
38
ACM/CQUPT-19/D.cpp
Normal file
38
ACM/CQUPT-19/D.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
long n,p,q;
|
||||||
|
cin>>n>>p>>q;
|
||||||
|
long arr[n];
|
||||||
|
long chafen[n+1];
|
||||||
|
for(long i=0;i<n;i++) {
|
||||||
|
cin>>arr[i];
|
||||||
|
}
|
||||||
|
chafen[n]=-arr[n-1];
|
||||||
|
for(long i=n-1;i>=0;i--) {
|
||||||
|
if(i==0) chafen[i] =arr[i];
|
||||||
|
else chafen[i]=arr[i]-arr[i-1];
|
||||||
|
}
|
||||||
|
long t;
|
||||||
|
cin>>t;
|
||||||
|
for(int i=0;i<t;i++) {
|
||||||
|
long l,r,v;
|
||||||
|
cin>>l>>r>>v;
|
||||||
|
chafen[l-1]+=v;
|
||||||
|
chafen[r]-=v;
|
||||||
|
}
|
||||||
|
long maxnum=0;
|
||||||
|
for(long i=0;i<n;i++) {
|
||||||
|
if(i==0) arr[i]=chafen[i];
|
||||||
|
else arr[i]=arr[i-1]+chafen[i];
|
||||||
|
if(maxnum<arr[i]) {
|
||||||
|
maxnum=arr[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maxnum=max(maxnum,p);
|
||||||
|
if(maxnum>=q) {
|
||||||
|
cout<<"3G win win!";
|
||||||
|
}else {
|
||||||
|
cout<<"3G wanna win win";
|
||||||
|
}
|
||||||
|
}
|
22
ACM/CQUPT-19/G.cpp
Normal file
22
ACM/CQUPT-19/G.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
int main() {
|
||||||
|
int sum=0,temp;
|
||||||
|
for(int i=0;i<3;i++) {
|
||||||
|
cin>>temp;
|
||||||
|
if((i==0 && temp<=80) || (i==1 && temp<=40)) {
|
||||||
|
cout<<-1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
sum+=temp;
|
||||||
|
}
|
||||||
|
if(sum>=175 && sum<220) {
|
||||||
|
cout<<3;
|
||||||
|
}else if(sum>=220 && sum<250){
|
||||||
|
cout<<2;
|
||||||
|
}else if(sum>=250) {
|
||||||
|
cout<<1;
|
||||||
|
}else {
|
||||||
|
cout<<-1;
|
||||||
|
}
|
||||||
|
}
|
49
ACM/CQUPT-19/I.cpp
Normal file
49
ACM/CQUPT-19/I.cpp
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include <algorithm>
|
||||||
|
using namespace std;
|
||||||
|
int n;
|
||||||
|
vector<int> credit;
|
||||||
|
vector<vector<int>> graph;
|
||||||
|
vector<bool> visited;
|
||||||
|
pair<long long, long long> dfs(int u, int parent) {
|
||||||
|
visited[u] = true;
|
||||||
|
long long notTaken = 0, taken = credit[u];
|
||||||
|
for (int v : graph[u]) {
|
||||||
|
if (v == parent) continue;
|
||||||
|
if (!visited[v]) {
|
||||||
|
auto child = dfs(v, u);
|
||||||
|
notTaken += max(child.first, child.second);
|
||||||
|
taken += child.first;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {notTaken, taken};
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
cin >> n;
|
||||||
|
credit.resize(n + 1);
|
||||||
|
graph.resize(n + 1);
|
||||||
|
visited.assign(n + 1, false);
|
||||||
|
for (int i = 1; i <= n; i++){
|
||||||
|
cin >> credit[i];
|
||||||
|
}
|
||||||
|
for (int i = 1; i <= n; i++){
|
||||||
|
int Ai;
|
||||||
|
cin >> Ai;
|
||||||
|
for (int j = 0; j < Ai; j++){
|
||||||
|
int v;
|
||||||
|
cin >> v;
|
||||||
|
graph[i].push_back(v);
|
||||||
|
graph[v].push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
long long ans = 0;
|
||||||
|
for (int i = 1; i <= n; i++){
|
||||||
|
if (!visited[i]){
|
||||||
|
auto res = dfs(i, -1);
|
||||||
|
ans += max(res.first, res.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout<<ans<<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user