e273: 微分入門課
e273: 微分入門課
C++:
測資很多,需優化I/O。
time:0.1s(90ms)
#0: 50% AC (90ms, 1.1MB)
通過檢測
#1: 50% AC (0.1s, 1.1MB)
通過檢測
memory used:1.1MB
code:
- #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- #pragma comment(linker, "/stack:200000000")
- #include<ios>
- char buf[1<<20],*p1=buf,*p2=buf;
- inline int getc(){
- return p1==p2&&(p2=(p1=buf)+fread_unlocked(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++;
- }
- inline void write(uint_fast16_t x){
- static int stk[6],top=0;
- int *ptr;
- ptr=&stk[0];
- while(x){*ptr=x%10;x/=10;ptr++;}
- ptr--;
- while(ptr>=(&stk[0])){putchar_unlocked(*ptr+'0');ptr--;}
- }
- inline int read(){
- uint_fast16_t ret=0;
- char ch=getc();
- while(ch>='0'&&ch<='9')
- ret=(ret<<1)+(ret<<3)+ch-'0',ch=getc();
- return ret;
- }
- int main(){
- uint_fast16_t a;
- while(a=read()){
- for(int i=a-1;i>=1;--i){
- write(read()*i);
- putchar_unlocked(' ');
- }
- redn();
- if(a==1)putchar_unlocked('0');
- putchar_unlocked('\n');
- }
- }
Python:
建表代替過慢的乘法即可AC
time:1.9s
memory used:6.8MB
code:
- from sys import stdin
- from sys import stdout
- d = {}
- for i in range(1,50): d[str(i)] = [str(i*k) for k in range(0,1000)]
- for s in stdin:
- n = int(s)
- if(n == 1):
- f = stdin.readline()
- stdout.write('0\n')
- else:
- f = [d[i][j] for i, j in zip(stdin.readline().split(),range(n-1,0,-1))]
- stdout.write(' '.join(f)+'\n')
本人的分享到此結束
若有更好的想法或建議,請在留言區留言喔
Comments
Post a Comment