救ƪ(˘-˘)ʃ
查看原帖
救ƪ(˘-˘)ʃ
1210473
ytezwsw_xjy楼主2024/7/17 14:53
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
long long s=0;
int main(){
	int n;
	n=read();
	for(int i=1;i<=n;i++){
		int x,y,z;
		z=1;
		x=read(),y=read();
		for(int j=y;j>=x;j--){
			s+=j*z;
			int b=j;
			int s2=0;
			while(b!=0){
				b/10;
				s2+=1;
			}
			z=z*10*s2;
		}
		long long s1=s%9;
		printf("%d",s1);
		puts("");
		s=0;
	}
	return 0;
}

全TLE`(>﹏<)′我知道3个循环肯定超时,那还有没有更优的方法

2024/7/17 14:53
加载中...