头像

Present.




离线:2天前


最近来访(78)
用户头像
种花家的兔兔
用户头像
Miracle狼魂
用户头像
L-China
用户头像
Xtt_1
用户头像
无名小卒x
用户头像
ヤ句号悠灬
用户头像
哦呼_2
用户头像
Iamyou_9
用户头像
子于鱼
用户头像
Finn2009
用户头像
叫我帅哥就好了丶
用户头像
努力学习鸭
用户头像
小郭冲冲冲
用户头像
Adair
用户头像
akakakakakak
用户头像
BT7274
用户头像
冷无情
用户头像
You星星还在吗
用户头像
纪念曾经的信念
用户头像
潘潘_the_panda

活动打卡代码 AcWing 797. 差分

#include<iostream>
using namespace std;

int a[100010];
int b[100010];

void insert(int l,int r,int c)
{
    b[l] += c;
    b[r + 1] -= c;
}

int main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    for(int i = 1;i <= n;i ++) insert(i,i,a[i]);
    while(m --)
    {
        int a,b,c;
        cin >> a >> b >> c;
        insert(a,b,c);
    }
    for(int i = 1;i <= n;i ++) 
    {
       b[i] += b[i - 1];
    }
    for(int i = 1;i <= n;i ++) cout << b[i] << " ";
    return 0;
}



Present.
10天前
#include <iostream>
using namespace std;
const int N = 1e9,N1 = 1e5;
long long res = 1;

void func(long long a,long long b)
{
    while(b)
    {
        res *= a;
        b --;
    }
}

int main()
{
    long long n,m;
    cin >> n >> m;
    if(n < N && m == 1) res = n;
    else if(n == 1) res = 1;
    else if(n > N1 || m > N1)  res = N + 1;
    else func(n,m);
    if(res > N) cout << "-1" << endl;
    else cout << res << endl;
    return 0;
}


活动打卡代码 AcWing 4728. 乘方

Present.
10天前
#include <iostream>
using namespace std;
const int N = 1e9,N1 = 1e5;
long long res = 1;

void func(long long a,long long b)
{
    while(b)
    {
        res *= a;
        b --;
    }
}

int main()
{
    long long n,m;
    cin >> n >> m;
    if(n < N && m == 1) res = n;
    else if(n == 1) res = 1;
    else if(n > N1 || m > N1)  res = N + 1;
    else func(n,m);
    if(res > N) cout << "-1" << endl;
    else cout << res << endl;
    return 0;
}


活动打卡代码 AcWing 4509. 归一化处理

Present.
10天前
#include <bits/stdc++.h>
using namespace std;
int a[1000];

int main()
{
    double n,a1;
    double sum = 0,isum = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++) 
    {
        cin >> a[i];
        sum += a[i];
    }
    a1 = sum / n;
    for(int i = 1;i <= n;i ++) 
    {
        isum += (1 / n) * (a[i] - a1) * (a[i] - a1);
    }
    for(int i = 1;i <= n;i ++) 
    {
        cout << (a[i] - a1) / sqrt(isum) << endl;    
    }
    return 0;
}



Present.
10天前
#include <bits/stdc++.h>
using namespace std;
int a[1000];

int main()
{
    double n,a1;
    double sum = 0,isum = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++) 
    {
        cin >> a[i];
        sum += a[i];
    }
    a1 = sum / n;
    for(int i = 1;i <= n;i ++) 
    {
        isum += (1 / n) * (a[i] - a1) * (a[i] - a1);
    }
    for(int i = 1;i <= n;i ++) 
    {
        cout << (a[i] - a1) / sqrt(isum) << endl;    
    }
    return 0;
}



Present.
10天前
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<pair<int,int>> v;
vector<int> v1;
int n,m;

bool cmp(pair<int,int> a,pair<int,int> b)
{
    if(a.first != b.first) return a.first < b.first;
    else return a.second < b.second;
}

int main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i ++)
    {
        int tmp = i;
        int isum = 0;
        while(tmp)
        {
            isum += tmp % 10;
            tmp /= 10;
        }
        v.push_back({isum,i});
    }
    sort(v.begin(),v.end(),cmp);
    for(auto c : v)
    {
       v1.push_back({c.second});
    }
    cout << v1[m - 1] << endl;
    return 0;

}



Present.
10天前
#include <iostream>

using namespace std;
int res;

int main()
{
    string s;
    cin >> s;
    int a,b,a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7,a8,b8,a9,b9;
    a = 1189,b = 841;
    a1 = b, b1 =  a / 2;
    a2 = b1,b2 = a1 / 2;
    a3=  b2,b3 = a2 / 2;
    a4 = b3,b4 = a3 / 2;
    a5 = b4,b5 = a4 / 2;
    a6 = b5,b6 = a5 / 2;
    a7 = b6,b7 = a6 / 2;
    a8 = b7,b8 = a7 / 2;
    a9 = b8,b9 = a8 / 2;
    if(s == "A0") cout << a << endl << b;
    if(s == "A1") cout << a1 << endl << b1;
    if(s == "A2") cout << a2 << endl << b2;
    if(s == "A3") cout << a3 << endl << b3;
    if(s == "A4") cout << a4 << endl << b4;
    if(s == "A5") cout << a5 << endl << b5;
    if(s == "A6") cout << a6 << endl << b6;
    if(s == "A7") cout << a7 << endl << b7;
    if(s == "A8") cout << a8 << endl << b8;
    if(s == "A9") cout << a9 << endl << b9;
    return 0;
}


活动打卡代码 AcWing 4652. 纸张尺寸

Present.
10天前
#include <iostream>

using namespace std;
int res;

int main()
{
    string s;
    cin >> s;
    int a,b,a1,b1,a2,b2,a3,b3,a4,b4,a5,b5,a6,b6,a7,b7,a8,b8,a9,b9;
    a = 1189,b = 841;
    a1 = b, b1 =  a / 2;
    a2 = b1,b2 = a1 / 2;
    a3=  b2,b3 = a2 / 2;
    a4 = b3,b4 = a3 / 2;
    a5 = b4,b5 = a4 / 2;
    a6 = b5,b6 = a5 / 2;
    a7 = b6,b7 = a6 / 2;
    a8 = b7,b8 = a7 / 2;
    a9 = b8,b9 = a8 / 2;
    if(s == "A0") cout << a << endl << b;
    if(s == "A1") cout << a1 << endl << b1;
    if(s == "A2") cout << a2 << endl << b2;
    if(s == "A3") cout << a3 << endl << b3;
    if(s == "A4") cout << a4 << endl << b4;
    if(s == "A5") cout << a5 << endl << b5;
    if(s == "A6") cout << a6 << endl << b6;
    if(s == "A7") cout << a7 << endl << b7;
    if(s == "A8") cout << a8 << endl << b8;
    if(s == "A9") cout << a9 << endl << b9;
    return 0;
}


活动打卡代码 AcWing 4653. 数位排序

Present.
10天前
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

vector<pair<int,int>> v;
vector<int> v1;
int n,m;

bool cmp(pair<int,int> a,pair<int,int> b)
{
    if(a.first != b.first) return a.first < b.first;
    else return a.second < b.second;
}

int main()
{
    cin >> n >> m;
    for(int i = 1;i <= n;i ++)
    {
        int tmp = i;
        int isum = 0;
        while(tmp)
        {
            isum += tmp % 10;
            tmp /= 10;
        }
        v.push_back({isum,i});
    }
    sort(v.begin(),v.end(),cmp);
    for(auto c : v)
    {
       v1.push_back({c.second});
    }
    cout << v1[m - 1] << endl;
    return 0;

}


活动打卡代码 AcWing 4644. 求和

Present.
11天前
#include <iostream>
using namespace std;

long long a[200010];
long long s[200010];

int main()
{
    int n;
    long long sum = 0;
    cin >> n;
    for(int i = 1;i <= n;i ++)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
    }
    for(int i = 1;i < n;i ++)
    {
        sum += a[i] * (s[n] - s[i]);
    }
    cout << sum << endl;
    return 0;
}