家人们,已经是90了,但是第三组异常了,请求帮助!!!Python语言

P2669 [NOIP2015 普及组] 金币

Shenxinxin @ 2023-02-25 16:18:24

x=int(input()) s=0 d=0 if 1<=x<=104: for i in range(1,x): while d<x: d+=i b=i break h=d-x if h==0: for i in range(1,b+1): s+=i2 print(s) else: for i in range(1,b+1): s+=i*2 s-=hb print(s)


by AKPC @ 2023-02-25 16:24:13

@Shenxinxin 插入代码


by Shenxinxin @ 2023-02-25 16:25:41

@A_Passing_Creeper 你好,我是第一此使用,请问您说的什么意思


by Shenxinxin @ 2023-02-25 16:27:40

@A_Passing_Creeper 插入代码指的是啥


by SPRINT_NOIP @ 2023-02-25 16:30:04

@Shenxinxin 就是指代码太乱了

你可以使用上方的插入代码插入python代码

比如

print("插入代码")

by SPRINT_NOIP @ 2023-02-25 16:30:43

@Shenxinxin 这样看的比较清楚

有利于我们看代码


by AKPC @ 2023-02-25 16:30:44

@Shenxinxin 就像这样

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define Inline __inline__ __attribute__((always_inline))
int block[100010],a[100010];
gp_hash_table<int,int>m[400];
template<typename T>
Inline void read(T &x){ x=0;register int f=1;register char c=getchar();while(c < '0' || c > '9'){if(c=='-')f=-1;c=getchar();}while(c >= '0' && c <= '9'){x=x*10+c-'0';c=getchar();}x*=f;}
template<typename T, typename ... Args>
Inline void read(T &x, Args &... y){ read(x);read(y...); }
signed main(){
    int n,f;
    read(n,f);
    int size=sqrt(n);
    for(int i=1;i<=n;++i){
        read(a[i]);
        block[i]=(i-1)/size+1;
        ++m[block[i]][a[i]];
    }
    for (int i=1;i<=f;++i){
        char opt;
        opt=getchar();opt=getchar();
        if (opt=='C'){
            int l,r;
            read(l,r);
            --m[block[l]][a[l]];
            ++m[block[l]][r];
            a[l]=r;
        }
        else if (opt=='Q'){
            int l,r,x,ans=0;
            read(l,r,x);
            for (int i=l;i<=min(r,block[l]*size);++i) if (a[i]==x) ++ans;
            if (block[l]!=block[r]) for(int i=r; i>=(block[r]-1)*size+1; --i) if (a[i]==x) ++ans;
            for (int i=block[l]+1;i<=block[r]-1;++i) ans+=m[i][x];
            printf("%lld\n",ans);
        }
    }
    return 0;
}

by SPRINT_NOIP @ 2023-02-25 16:31:12

@A_Passing_Creeper 是的


by Shenxinxin @ 2023-02-25 16:33:15

x=int(input())
s=0
d=0
if 1<=x<=10**4:
  for i in range(1,x):
    while d<x:
      d+=i
      b=i
      break
  h=d-x
  if h==0:
    for i in range(1,b+1):
      s+=i**2
    print(s)
  else:
    for i in range(1,b+1):
      s+=i**2
    s-=h*b
    print(s)

@SPRINT_NOIP


by Shenxinxin @ 2023-02-25 16:33:39

x=int(input())
s=0
d=0
if 1<=x<=10**4:
  for i in range(1,x):
    while d<x:
      d+=i
      b=i
      break
  h=d-x
  if h==0:
    for i in range(1,b+1):
      s+=i**2
    print(s)
  else:
    for i in range(1,b+1):
      s+=i**2
    s-=h*b
    print(s)

@A_Passing_Creeper


by SPRINT_NOIP @ 2023-02-25 16:43:19

@Shenxinxin

k = eval(input())
n = 1
s = 0
while n * (n + 1) / 2 < k:
    n += 1
for i in range(1, n):
    s += i * i
s += (k - (n - 1) * n / 2) * n
print(int(s))

| 下一页