We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#include<iostream> #include<cmath> using namespace std; typedef long long ll; int main() { cin>>n>>m; int a[n]; for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++){ int j=i-m%n; //通过公式 i->(i+m )%n实现位置的变换,可以逆转换变换后的a[j]=a[i+kn-m] , if(j<0) cout<<a[j+n]; //这里的k为使kn-m小于0时的最小值,如果其绝对值大于i只需k+1即可,所以可转换为i-m%n判断正负即可 else cout<<a[j]; //下标之间的逆转换只用一个式子即可表达,就cout<<a[(j>0?j:(j+n))] if(i<n-1)cout<<" "; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: