提交记录 27950


用户 题目 状态 得分 用时 内存 语言 代码长度
wys test. 自定义测试 Accepted 100 9.26 us 12 KB C++ 1.65 KB
提交时间 评测时间
2025-02-20 20:08:30 2025-02-20 20:08:31
#include <cstdio>
#include <cstring>

#if defined(__GNUC__)
    #if defined(__clang__)
        #define COMPILER_FMT "Clang: %s"
    #else
        #define COMPILER_FMT "GNUC: %s"
    #endif
    #define COMPILER_VERSION __VERSION__
#elif defined(_MSC_VER)
    #define COMPILER_FMT "MSVC: %d"
    #define COMPILER_VERSION _MSC_FULL_VER
#else
    #error Please add your compiler here.
#endif

static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
				unsigned int *ecx, unsigned int *edx)
{
	/* ecx is often an input as well as an output. */
	asm volatile("cpuid"
	    : "=a" (*eax),
	      "=b" (*ebx),
	      "=c" (*ecx),
	      "=d" (*edx)
	    : "0" (*eax), "2" (*ecx)
	    : "memory");
}

static inline void __cpuid(unsigned *cpuinfo, int op) {
	cpuinfo[0] = op;
	cpuinfo[2] = 0;
	native_cpuid(&cpuinfo[0], &cpuinfo[1], &cpuinfo[2], &cpuinfo[3]);
}

int main() {
    printf("Built with " COMPILER_FMT "\n", COMPILER_VERSION);
    printf("C++ version: %ld\n", __cplusplus);
	
	unsigned CPUInfo[4] = {0};
	unsigned   nExIds, i =  0;
	char CPUBrandString[0x40];
	// Get the information associated with each extended ID.
	__cpuid(CPUInfo, 0x80000000);
	nExIds = CPUInfo[0];
	for (i=0x80000000; i<=nExIds; ++i)
	{
		__cpuid(CPUInfo, i);
		// Interpret CPU brand string
		if  (i == 0x80000002)
			memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
		else if  (i == 0x80000003)
			memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
		else if  (i == 0x80000004)
			memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
	}
	//string includes manufacturer, model and clockspeed
	printf("CPU: %s\n", CPUBrandString);
	
	printf("Pointer width (bits): %d\n", 8 * sizeof(char *));
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #19.26 us12 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-02-22 02:11:47 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠